[Python-Dev] New include statement
M.-A. Lemburg
mal@lemburg.com
Sat, 05 Jul 2003 13:25:09 +0200
Ebbinge, Onno wrote:
> Wouldn't it be very useful if it would be possible to include C header
> files so that you could easily access to the local shared libraries
> (e.g., a .so or .dll)? A simple example:
>
>
>>>>include <time.h>
>>>>secs = time.time(None)
>>>>tm = time.localtime(secs)
>>>>print 'The time is (ANSI format): %d-%d-%d %d:%d:%d\n' % (
>
> ... tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
> ... tm.tm_min, tm.tm_sec)
> The time is (ANSI format): 2003-7-2 13:52:31
>
> Ok, the standard C time.h is totally not interesting in
> Python because it has it's own time module, but able to access
> other (os specific!) shared libraries is very useful! Access
> to ufs/ufs/quota.h on my FreeBSD box would be very simple
> this way (instead of wrapping/compiling/etc the whole thing).
>
> The new include statement should wrap #define's, struct's, function
> declarations and such found in the header files in a module object.
> This would be a _very_ general way to access shared libraries and OS
> API's. I even think it would dramatically simplify the standard or
> third party modules for python.
>
> But... is this possible? Would it have the big advantages I think
> it would have?
I think the closest you can get to this is by using Thomas Heller's
ctypes extension:
http://starship.python.net/crew/theller/ctypes/
Not sure whether it works on FreeBSD. The web page says that it
need libffi.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Jul 05 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2003-07-01: Released mxODBC.Zope.DA for FreeBSD 1.0.6 beta 1