a = b = 1 just syntactic sugar?
ed at membled.com
Wed Jun 4 21:31:53 CEST 2003
Erik Max Francis <max at alcyone.com> writes:
>>Is there a way to write an expression which sets b and does return
>Sure, with difficulty. But if the language has been specifically
>designed so that assignment is a statement, not an expression,
>wouldn't you think it's not considered such a good idea?
I was thinking only of unusual circumstances. I certainly wouldn't
want to write unidiomatic code just for the sake of setting two
variables at once. But I can think of places like lambda-expressions
where this could be very useful, and possibly make the code clearer
than using an alternative style. If, in practice, it turns out to
make the code less clear and less maintainable, then of course I
wouldn't do it.
Ed Avis <ed at membled.com>
More information about the Python-list