[Pyrex] How to specify __contains__ method?

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Apr 15 01:57:35 CEST 2004


> 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 at cosc.canterbury.ac.nz	   +--------------------------------------+





More information about the Pyrex mailing list