[Tutor] odd behavior within __init__
Max Noel
maxnoel_fr at yahoo.fr
Thu Apr 14 13:15:09 CEST 2005
On Apr 14, 2005, at 12:58, Orri Ganel wrote:
>>>> a = Node(1)
>>>> b = Node(a)
> 12932600 12932600
> 1
>>>> id(b)
> 12960632
>
> Any ideas on why this happens, or suggestions as to how to implement
> the behavior I'm looking for (in which b and a would refer to the same
> object, have the same id, etc.), would be greatly appreciated.
Well, if you want b and a to refer to the same object, just use b = a.
Everything is a reference in Python, make use of this feature. (at that
point, I expect Alan to drop in and explain why what I said is not
entirely accurate, but good enough ;) )
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting
and sweating as you run through my corridors... How can you challenge a
perfect, immortal machine?"
More information about the Tutor
mailing list