[Tutor] is gotchas?

wesley chun wescpy at gmail.com
Wed Nov 8 05:47:26 CET 2006


> > a is b <==> id(a) == id(b)
>
> No, not necessarily. id's are recycled which can lead to unexpected
> behaviour when comparing them. See for example this thread on c.l.py:
> http://tinyurl.com/yflknx

wow, that is totally mind-blowing.. good post. i think that for most
normal objects that are *not* created on the fly, the comparison is
ok.  still, i'd stick to using is... as-is.

-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list