Python equivilent to dlopen/dlsym ?

Michael Hudson mwh at python.net
Fri Jun 1 13:15:51 EDT 2001


offer at sgi.com (Nhi Vanye) writes:

> What would be the python equivilent of dlopen()/dlsym(). I'm trying to
> prototype some C code that will use dlopen to open a shared library and
> ldsym() to call a particular function in it.
> 
> The python file that implements the functions is listed in a runtime
> configuration file. Because the configuration file will list multiple
> python modules that each have the same function defined (I'll will chain
> them when I call them) I don't want to pollute the name spaces.
> 
> Any clues ?

Does execfile do what you want:

d = {}
execfile("/path/to/file.py",d,d)
sym = d[symbol_name]

?  If not, I'm not sure what you're after.

Cheers,
M.

-- 
  Our lecture theatre has just crashed. It will currently only
  silently display an unexplained line-drawing of a large dog
  accompanied by spookily flickering lights.
     -- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year)



More information about the Python-list mailing list