Georg Grabler <[EMAIL PROTECTED]> wrote: > There's a C library which i'd like to have python bindings for. I havn't > known anything before about how to write python bindings for a C library. > > I succeeded now by using distutils to write the first bindings for functions > and similar. > > Now, it seems as something is blocking my brain. For the library, i > need "custom" types, so types defined in this library (structures), > including pointers and similar. > > I've been thinking about what i will need to represent this lists in python. > I thought about creating an external python object, providing "information" > i get from the list in C structures which can be converted. > > Basically, it are list of packages, which have several attributes (next, > prev, etc). But i don't know how to supply a proper list from the binding / > object written in C. > > Any suggestions or hints about this?
Sounds like a job for ctypes which is bundled with py 2.5. http://docs.python.org/lib/module-ctypes.html It is great for access C libraries (assuming you have a shared library (.so or .dll). You'll end up writing python code rather than C code which you'll enjoy! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list