Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42910
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: is operator versus id() function |
| Date | 2013-04-06 14:35 +0100 |
| Message-Id | <pan.2013.04.06.13.35.03.48000@nowhere.com> |
| Newsgroups | comp.lang.python |
| References | <ed17e4ac-2000-42ef-aa2b-69ff421ae3fa@googlegroups.com> |
| Organization | Zen Internet |
On Fri, 05 Apr 2013 06:49:14 -0700, Candide Dandide wrote: > So, could someone please explain what exactly the is operator returns ? > The official doc says : > > The ‘is‘ operator compares the identity of two objects; the id() > function returns an integer representing its identity (currently > implemented as its address). The docs are correct. But an identity is only unique for the lifetime of the object, so "x is y" and "id(x)==id(y)" are only equivalent if the lifetimes of x and y overlap. If the objects have disjoint lifetimes (i.e. one is created after the other has been destroyed), then it's possible for id() to return the same value for both objects, so id(x)==id(y) can return a "false positive" result, as happened in your example.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
is operator versus id() function Candide Dandide <c.candide@laposte.net> - 2013-04-05 06:49 -0700
Re: is operator versus id() function Arnaud Delobelle <arnodel@gmail.com> - 2013-04-05 15:53 +0100
Re: is operator versus id() function candide <c.candide@laposte.net> - 2013-04-05 09:40 -0700
Re: is operator versus id() function Tim Delaney <timothy.c.delaney@gmail.com> - 2013-04-06 06:57 +1100
Re: is operator versus id() function candide <c.candide@laposte.net> - 2013-04-05 09:40 -0700
Re: is operator versus id() function Nobody <nobody@nowhere.com> - 2013-04-06 14:35 +0100
csiph-web