I have been wondering for a while if there is easier way to assign class attributes to method local namespace. For example, in dosomething method, I explicitly make
dosomething
I found another way:
def dosomething(self): for key in ['a', 'b']: exec('{} = self.{}'.format(key, key)) return(a + b)
I don't know if this is dangerous or not. Would be great if someone can comment on this.