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
Hi, Just curious about the schedule for making everything Python 1.5.2... -- Cheers, --ldl ----------------------------------------------------------------------------- LD Landis ldl@HealthPartners.Com N0YRQ Voice 612/883-5511 Fax 612/883-6363 HealthPartners, 8100 34th Avenue So, PO Box 1309, Minneapolis, MN 55440-1309 Shape your life not from your memories, but from your hopes. (Borrowed) -----------------------------------------------------------------------------
On Wed, 14 Apr 1999, Mike Pelletier wrote:
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
Weird. My guess is that one form returns the object wrapped in an acquisition wrapper and the other does not. However their __str__ or __repr__ methods return the base object address. Pavlos
participants (3)
-
LD Landis -
Mike Pelletier -
Pavlos Christoforou