a = b = 1 just syntactic sugar?
Ed Avis
ed at membled.com
Wed Jun 4 15:49:37 EDT 2003
Robin Munn <rmunn at pobox.com> writes:
[example of a = b = [] versus separate assignments]
>It seems the RHS is only evaluated once in chained assignment, at
>least as of Python 2.2.2.
Yes, it has to be this way. You can think of [] as a function which
returns a new list. If the RHS were evaluated twice in
a = b = []
then [] would be called twice and you'd get two different lists (as
happens when there are two different assignment statements).
--
Ed Avis <ed at membled.com>
More information about the Python-list
mailing list