Question: "load"ing a shared object in python

Rick L. Ratzel rlratzel at enthought.com
Thu Jan 27 12:48:23 EST 2005


Pro Grammer <a at b.c> writes:

> Hello, all,
> I am not sure if this is the right place to ask, but could you kindly tell me
> how to "load" a shared object (like libx.so) into python, so that the methods in
> the .so can be used? That too, given that the shared object was written in c++,
> compiled with g++ ?
> Thanks,
> Pro Grammer

   Will the dl standard library module help you?  From the Python docs at:

http://docs.python.org/lib/module-dl.html

Example:

>>> import dl, time
>>> a=dl.open('/lib/libc.so.6')
>>> a.call('time'), time.time()
(929723914, 929723914.498)

   I'm guessing that there might be some C++ issues, but maybe it's worth
looking into.

Rick



More information about the Python-list mailing list