[Pyrex] Problems with cimport

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Nov 12 00:41:02 CET 2003


Francesc Alted <falted at openlc.org>:

> --begin file dishes.pxd--
> cdef enum otherstuff:
>     sausage, eggs, lettuce
> 
> cdef struct spamdish:
>     int oz_of_spam
>     otherstuff filler
> --end file dishes.pxd--
> 
> --begin file restaurant.pyx--
> cimport dishes
> 
> ...
> 
>     d.filler = dishes.sausage
                 ^^^^^^^^^^^^^^

There is no C entity called 'sausage' defined in dishes.pxd.

If sausage is a C function or extension type, you'll need
to declare it in dishes.pxd. If it's a Python attribute,
you'll need to import dishes as well as cimporting it,
since a cimport doesn't imply a Python import.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list