[EMAIL PROTECTED] wrote: > I was shocked a while ago when a discovered that in Python you can't > do a multiline assignment > with comments between the lines. > > For example, let's say I want to assign a bunch of variables to an > initial, single value. In C or a similar language you would do: > > CONSTANT1 = > /* This is some constant */ > CONSTANT2 = > CONSTANT3 = > > /*This is yet some other constant */ > CONSTANT = > > 1; >
Yuck! No way!! If you *want* to make your code that hard to read, I'm sure you can find lots of ways to do so, even in Python, but don't expect Python to change to help you toward such a dubious goal. Seriously, examine your motivations for wanting such a syntax. Does it make the code more readable? (Absolutely not.) Does it make it more maintainable. (Certainly not -- consider it you needed to change CONSTANT2 to a different value some time in the future.) Gary Herron > In Python, you usually can use parentheses to split something over > several lines. But you can't use parentheses for an assignment of > several lines. For that, you can use the line continuation character > ('\'): > > CONSTANT1 = \ > CONSTANT2 = \ > CONSTANT3 = \ > 1 > > But I realized that you can't do this: > > CONSTANT1 = \ > # Oops... syntax error > CONSTANT2 = \ > CONSTANT3 = \ # This is also a syntax error > # And this too \ > 1 > > Does anyone know of a way to put the comments between lines like that? > I find this limitation very annoying. > -- http://mail.python.org/mailman/listinfo/python-list