descriptor dilemma
Jeff Epler
jepler at unpythonic.net
Wed May 4 12:21:09 EDT 2005
On Wed, May 04, 2005 at 09:14:18AM -0700, Sébastien Boisgérault wrote:
>
> Yup ?!? Weird ... especially as:
>
> >>> id(c.f) == id(C.__dict__['f'].__get__(c,C))
> True
Here, c.f is discarded by the time the right-hand-side of == is
executed. So the object whose id() is being calculated on the
right-hand-side could turn out to be the same, since the two objects
have disjoint lifetimes.
Here are some more cases of the same thing:
>>> id([]) == id([])
1
>>> id([]) == id([1])
1
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050504/1388273f/attachment.sig>
More information about the Python-list
mailing list