On Oct 2, 2008, at 8:25 AM, Uwe Schmitt wrote:
> Hi,
>
> in order to resolve a name conflict concerning enums I followed the
> description from
> http://docs.cython.org/docs/sharing_declarations.html#using-cimport-
> to-resolve-naming-conflicts
>
> Here comes my code:
>
> ----- minimal.pxd ------------------------
>
> cdef extern from "minimal.h":
>
> cdef enum test:
> A
>
> ----- minimal.pyx -------------------------
>
> cimport minimal
>
> A = minimal.A
>
> -------------------------------------------
>
> which does not work. Cython says "Assignment to non-lvalue 'A'"
> If I modify it to "cdef int A = minimal.A" I get "'A' redeclared".
minimal.pxd and minimal.pyx have a special relationship to each
other, specifically, minimal.pxd defines the interface of the things
implemented in minimal.pyx (for use from other modules). The
"imaginary" part of "imaginary module" is important, as once you have
defined a .pyx file the module is no longer imaginary.
> So, how can I provide the user of my module the same enums
> as defined internally ???
Simply rename minimal.pxd to something else.
As a side note, for non-extern enums, you can write
cdef public enum:
...
and it will automatically export the enum variables to your (python-
level) module scope. Unfortunately, it doesn't yet work for extern
enums http://trac.cython.org/cython_trac/ticket/92
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev