logo       

Re: How to specify __contains__ method?: msg#00022

python.pyrex

Subject: Re: How to specify __contains__ method?

> When I compile the following simple example:
>
> cdef class foo:
> def __contains__(self, key):
> return 1
>
> I get the error message:
>
> d:\msl\gb\python\my\Matrix\bug2.pyx:3:11: Return with value in void function

This appears to be a bug. I'll look into it.

> If I change "def" to "cdef int", it gets past Pyrex but the C compiler
> complains:

That's probably a bug too, but in any case this isn't what
you want to do. Special methods are supposed to be declared
with def, not cdef. Probably I should disallow using cdef
in this case.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg@xxxxxxxxxxxxxxxxxxxxx +--------------------------------------+


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise