[Pyrex] Cannot cdef __init__?

Paul Prescod paul at prescod.net
Sun Jan 18 07:28:43 CET 2004


Forgot to share this with the whole list.

Paul Prescod wrote:

> Does this variant do what you want?
> 
> cdef struct pair:
>     int x
>     int y
> 
> cdef class Pair:
>     cdef pair p
> 
> cdef class Fred:
>     cdef Pair p
> 
>     def __init__(self, Pair p):
>         self.p = p
> 
>     cdef x(self):
>         pass
> 
>     def foo(self):
>         return self.p.x + self.p.y
> 
> def test(a, b):
>     return Fred(Pair(a, b))
> 
> print test(3, 4)
> 
> 






More information about the Pyrex mailing list