Tuple assignment and generators?
Michele Simionato
michele.simionato at gmail.com
Fri May 5 03:20:39 EDT 2006
Carl Banks wrote:
>>> q = 0
> >>> r = 0
> >>> s = 0
> >>> id(q)
> 134536636
> >>> id(r)
> 134536636
> >>> id(s)
> 134536636
>
> It is okay with constant object, really.
No:
>>> r=100001
>>> s=100001
>>> t=100001
>>> id(r)
135620508
>>> id(s)
135620532
>>> id(t)
135104688
It worked with the number 0 because of an implementation accident,
in general Python can use different ids for constant objects that are
equals in the == sense.
Michele Simionato
More information about the Python-list
mailing list