[Pyrex] instances of cdef'ed classes problem
Stefan Behnel
behnel_ml at gkec.informatik.tu-darmstadt.de
Thu Jul 6 17:36:27 UTC 2006
Hi!
Test Drive wrote:
> cdef class Parrot:
>
> cdef void describe(self):
> print "This parrot is resting."
>
> cdef class Norwegian(Parrot):
>
> cdef void describe(self):
> Parrot.describe(self)
> print "Lovely plumage!"
>
> >>> p=parrot.Parrot()
> >>> p.decribe()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: 'parrot.Parrot' object has no attribute 'decribe'
obviously :)
> Now the problem is when i say dir(p)
> i donot see the describe method, nor am i able to call it.
> Is it not possible to create an instance of cdef'ed class?
>
> any clues?
>
> thanks in adavnce
Check your spelling before complaining? :)
Just kidding...
Your method is a C method ("c"def!), so Python cannot see it. Make it a normal
method without the "cdef" if you want to call it from Python.
Stefan
More information about the Pyrex
mailing list