Re: defining module constants

Stefan Behnel <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
Hi,

Rob Shortt wrote:
> I'm creating some python bindings to a C library.  I've defined
> everything from the lib's header file in my pxd file and would like to
> expose many of the defined enums in my pyrex module, not as members of a
> class, but toplevel to my module.

What I did for lxml was to write a little script that parses the HTML
documentation of libxml2 (which would be the header file in your case) for
error state enums and write that directly into both a .pxi and a .pxd file.
They change from time to time with new releases of libxml2, so rerunning the
script gets them updated.

http://codespeak.net/svn/lxml/trunk/update-error-constants.py
http://codespeak.net/svn/lxml/trunk/src/lxml/xmlerror.pxd
http://codespeak.net/svn/lxml/trunk/src/lxml/xmlerror.pxi

Hope that helps,

Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.