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
You can easily solve this problem with a tradeoff, by storing the variables in a dictionary.
data = {}
copy_to_local_variables = ["a", "b", "c", "d"]
for var_name in copy_to_local_variables:
data[var_name] = getattr(self, var_name)
(Though I am unable to understand why you need to copy class attributes to method local namespace)