I'm certain I must be doing something stupid here, but I can't figure out what... I have a set of objects "A" in a list, which contain references to a set of objects "B". I'm simply trying to determine whether a particular object "A" refers to a particular object "B". I can't understand the behaviour I'm seeing when I try to do so: Python 1.5.2b1 (#2, Jan 18 1999, 11:01:20) [GCC 2.7.2.1] on freebsd3 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
from Main import app hg = app.devel.hg list = hg.entries.values() user = hg.users['Mike']
list is now a list of "A" type object, and user is now the "B" type object in question.
print list[0].user, user <User instance at 0x8444100> <User instance at 0x8444100>
By eyeball (and design), they are the same object.
print list[0].user == user 0 print list[0].user != user 1
Python, however, disagrees! How can two objects occupy the same location in memory, and not be judged equal by Python? The class of the object compared against itself above does not define any hooks other than __init__. It inherits from Persistent and Aquisition.Implicit. (I know, it's a few ancestors short of a full load.) I'm afraid it's just too many for me. Can anyone shed some light? Mike. -- --- | Mike Pelletier Work: 519-746-1607 /opeware! | Software Developer Home: 519-725-7710 --- | mike@zopeware.com Fax: 519-746-7566 http://www.zopeware.com | Zopeware is not endorsed by Digital Creations