a = b = 1 just syntactic sugar?

Asun Friere afriere at yahoo.co.uk
Tue Jun 3 23:13:27 EDT 2003


"Batista, Facundo" <FBatista at uniFON.com.ar> wrote in message news:<mailman.1054662726.12651.python-list at python.org>...

> >>> 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).
> 
They are, but this has little to do with the fact that both assigned
their values using a single statement. ie:
>>>sys.ps1 = '? '
? a = 1
? b = 1
? a is b
1




More information about the Python-list mailing list