Wednesday, April 13, 2011

Python dlopen/dlfunc/dlsym wrappers

Anybody knows if actually exists a wrapper or ported library to access to Unix dynamic linker on Python?

From stackoverflow
  • Would ctypes do what you want?

  • The module is called dl:

    >>> import dl
    >>> dl.open("libfoo.so")
    <dl.dl object at 0xb7f580c0>
    >>> dl.open("libfoo.so").sym('bar')
    1400432
    

    ... though it's nasty and you might want to consider using ctypes or an extension module.

    Edit

    Apparently, dl is deprecated in 2.6 so you'll want to use ctypes which has a better API anyhow.

    Devin Jeanpierre : deprecation of dl in favor of ctypes confirms that my near-guess of an answer was correct. *phew*.

0 comments:

Post a Comment