object identity and equivalence

Werner Schiendl ws-news at gmx.at
Tue Nov 20 14:30:09 CET 2001


Hi,

it obviously depends if the two occurences are fed into the compiler at the
same time or not.
Trying the following script (not interactive shell)

x = 10.0
y = 10.0

print "x is y", x is y

outputs x is y 1 on my machine.

hth
Werner

"Marcin 'Qrczak' Kowalczyk" <qrczak at knm.org.pl> wrote in message
news:slrn9vkjt8.i79.qrczak at qrnik.zagroda...
> Mon, 19 Nov 2001 18:44:16 -0000, Sandy Norton <sandskyfly at hotmail.com>
pisze:
>
> >>>> x = 10.0
> >>>> y = 10.0
> >>>> x is y
> > 0
>
> The result is different when the first two statements are written in
> one line:
>
> >>> x = 10.0; y = 10.0
> >>> x is y
> 1
>
> So identity of builtin immutable types is indeed very ill-defined.
> It depends on line breaks. It depende whether statements are entered
> interactively or they come from a script. And of course it may be
> different in other versions of the interpreter.
>
> --
>  __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
>  \__/
>   ^^
> QRCZAK





More information about the Python-list mailing list