Hi All,

A fairly brief question: how does one get a Cython class to inherit from a Python class defined in another file? Say I have class A defined in foo.py, and I want to define a class, B, in a separate .pyx file, that inherits from A. In my .pyx file I currently have something like the following:

from foo import A
...
cdef class B(A):
        ...

but I get an "'A' is not a type name" error when building. I found the following in the documentation.

A complete definition of the base type must be available to Cython, so if the base type is a built-in type, it must have been previously declared as an extern extension type. If the base type is defined in another Cython module, it must either be declared as an extern extension type or imported using the cimport statement.

I guess instead of my import statement I need to have something like

cdef extern from "foo.py":
        ...

at the top of my .pyx file, but can't figure out what type information I need to provide Cython. Apologies, as I'm sure the answer is obvious, but any help would be greatly appreciated.

Thanks,

Dan.
 
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to