a = b = 1 just syntactic sugar?

Joshua Marshall joshway_without_spam at myway.com
Tue Jun 3 14:38:30 EDT 2003


Kendear <kendear at nospam.com> wrote:

> Batista, Facundo wrote:
>> "b = 1" does not return 1, just returns b. a and b are the same object now
>> (they are not just equal, they are the very same).

> if b = 1 returns b, then why can't you say  a = (b = 1)  ?

It's incorrect.  "b = 1" does not return (evaluate to) anything,
because it's not an expression.  "a = b = 1" is an assignment
statement which assigns 1 to "a", then to "b".




More information about the Python-list mailing list