开发者

cython inheritance

I have a A.pxd (with just declaration of functions) and A.pyx that contains just a class A with all the function body.

Than I have B that inherits from A,

and for B I have B.pxd with some functions

B.pyx

class Bclass(A):
    #all the funcions body

I want to now how to tell to B.pyx to ricognise A as a type name?

开发者_运维问答what i do is:

B.pyx

cimport A
import A
from A import Aclass
cdef Bclass(Aclass):
   #body

but it says me: A is not a type name

If i do this in just one file.pyx it works without problems but working with files.pxd it does not go.


Use

from A cimport Aclass
cdef class Bclass(Aclass):
    # ...

or

cimport A
cdef class Bclass(A.Aclass):
    # ...

Note that Aclass must be cdef'fed class, Cython extension types cannot inherit from Python classes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜