a = b = 1 just syntactic sugar?

Just just at xs4all.nl
Thu Jun 5 08:09:42 EDT 2003


In article <3EDF2FEE.7D031B68 at engcorp.com>,
 Peter Hansen <peter at engcorp.com> wrote:

> Asun Friere wrote:
> > 
> > ? a = 556; b = 556
> > ? a is b
> > 1
> 
> Hmm?  That one surprises me.  I wonder how the compiler is
> treating that line...  I would have though ; basically had
> the same effect as a line seperator.

It's only different in interactive mode: when they're on separate lines 
they get compiled separately into separate code objects, each having 
their own set of constants. When they're compiled together there's just 
one code object and the compiler will generate only one constant.

Just




More information about the Python-list mailing list