a = b = 1 just syntactic sugar?

Brian Quinlan brian at sweetapp.com
Tue Jun 3 14:06:43 EDT 2003


> >>> a = b = 2
> >>> b
> 2
> >>> a
> 2
> >>> id(a)
> 135286056
> >>> id(b)
> 135286056
> >>> a is b
> 1
> 
> "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).

This isn't quite true either. "b = 1" doesn't return anything. In fact,
binding "a" is done first.

Cheers,
Brian






More information about the Python-list mailing list