which methods to use?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Mar 29 13:55:04 EDT 2007
En Thu, 29 Mar 2007 01:56:15 -0300, Steven D'Aprano
<steve at REMOVE.THIS.cybersource.com.au> escribió:
> By the way, "id(obj) == id(another_object)" is just a long way of writing
> "obj is another_object".
Just as a side note: that's not true, testing by id() only works if both
objects are alive at the same time.
py> id(object()) == id(object())
True
py> object() is object()
False
So using the `is` operator is the only safe way to test for identity.
--
Gabriel Genellina
More information about the Python-list
mailing list