I have a long list of assignments like below which copies all local variables into class variables in the constructor.
self.x = x
self.y = y.
....
The reason is that I have complicated initialization expressions and and I'm using x
rather than self.x
for readability for all the intermediate computations.
I tried to simplify this block to something like
for name in ["x","y",...]:
eval("self.%s = %s"%(name, name))
However, I'm getting SyntaxError
inside eval
, is their a better way to cut down this list?