[pygtk] Re: [Python-Dev] a bit confused about the new type/class stuff (original) (raw)
Skip Montanaro skip@pobox.com (Skip Montanaro)
Thu, 4 Oct 2001 08:41:48 -0500
- Previous message: [pygtk] Re: [Python-Dev] a bit confused about the new type/class stuff
- Next message: [Python-Dev] Making setup.py a little more flexible
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> >>> l
>> [<Button object (GtkButton) at 0x8293134>, <Button object (GtkButton) at 0x8296ac4>, <Button object (GtkButton) at 0x8397fb4>]
>> >>> b = l[0]
>> >>> b in l
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> TypeError: Button.__cmp__(x,y) requires y to be a 'Button', not a 'instance'
A brief conversation with Guido cleared up what was happening. In my class hierarchy I didn't implement cmp, but I did implement getattr, which was delegating most things to the underlying Gtk widget, so
b.__cmp__(l)
became
b._real_widget.__cmp(l)
which then barfed.
Writing a cmp method that does the right thing cleared up the problem.
Skip
- Previous message: [pygtk] Re: [Python-Dev] a bit confused about the new type/class stuff
- Next message: [Python-Dev] Making setup.py a little more flexible
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]