Can't do a multiline assignment!

Marco Mariani marco at sferacarta.com
Thu Apr 17 17:54:03 CEST 2008


s0suk3 at gmail.com wrote:

> Yes, it makes it more readable. And yes, it does make it (a lot) more
> maintainable. Mainly because I don't have those four variables, I have
> about thirty. And I think I won't need to one or two of them, but
> maybe all of them at once.

have fun with locals(), then (but please feel dirty :-)

loc = locals()
for var in [
         'foo',     # INSERT
         'bar',     # COMMENT
         'baz'      # HERE
         ]:
     loc[var] = 42




More information about the Python-list mailing list