[Pyrex] How to specify __contains__ method?
Gary Bishop
gb at cs.unc.edu
Sun Apr 11 22:48:50 CEST 2004
Great. That fixes the first problem. I found that line but didn't see
how to change it. I'll see if I can figure out the compiler so I can
help with this kind of stuff.
Now the second problem still remains. That is demonstrated by:
cdef class foo:
cdef int val
def __init__(self):
self.val = 0
cdef class fee(foo):
def bof(self):
print 'fee bof', self.val
cdef class faa(fee):
def bof(self):
print 'foo bof', self.val
Now at the python command prompt:
>> import bug2
>> foo = bug2.foo()
>> fee = bug2.fee()
>> faa = bug2.faa()
>> fee.bof()
fee bof 0
>> faa.bof()
faa bof
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "d:\msl\gb\python\my\Matrix\bug2.pyx", line 17, in bug2.faa.bof
print 'bof', self.val
AttributeError: 'bug2.faa' object has no attribute 'val'
faa appears to not realize it has direct access to self.val.
Thanks
gb
On Sun, 11 Apr 2004 21:40:01 +0200 "Andreas Kostyrka"
<andreas at mtg.co.at> wrote:
> Am So, den 11.04.2004 schrieb Gary Bishop um 20:43:
> Known bug ;)
> [I'm just not sure if I mailed it away or if I forgot to mail the bugfix
> in ;) ]
> Ok, in Pyrex/Compiler/TypeSlots.py look for a line like that:
> MethodSlot(objargproc, "sq_contains", "__contains__"),
> change it then to:
> MethodSlot(cmpfunc, "sq_contains", "__contains__"),
More information about the Pyrex
mailing list