Re: Help for public Python extension types.
Robert Bradshaw <[email protected]> Thu, 26 Jun 2008 23:10:27 -0700
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
On Jun 26, 2008, at 8:13 PM, Daehyok Shin wrote:
> Hi. Let me ask about the public Python extension types.
> I created the following files (simplified than actual files) to enable
> both other Pyrex and C programs to access the variable i in the X
> extension type. But, I found the generated header file, test.h, does
> not contain the variable i in its declaration of X.
> Any idea about what's wrong in the files? Right now, I am using Pyrex
> ver. 0.9.8.4.
> Thanks in advance.
>
> ---- test.pxd ----
> cdef public class X[object x_object, type x_type]:
> cdef public int i
>
> --- test.pyx -----
> cimport test
> cdef public class X[object x_object, type x_type]:
> pass
Here you're declaring a new class called X in your pyx file. What you
want to do is
from test cimport X
or
cimport test # use test.X to refer to the class.
- Robert