Python equivilent to dlopen/dlsym ? 
Author Message
 Python equivilent to dlopen/dlsym ?

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 ?

richard.

--
Richard Offer                         Technical Lead, Trust Technology.
"Specialization is for insects"
__________________________________________ http://www.*-*-*.com/



Wed, 19 Nov 2003 00:27:08 GMT  
 Python equivilent to dlopen/dlsym ?

Quote:

> 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)



Wed, 19 Nov 2003 01:15:51 GMT  
 Python equivilent to dlopen/dlsym ?

Quote:


>> 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.

Good enough.

Thanks.

Quote:

>Cheers,
>M.

richard.
--
Richard Offer                         Technical Lead, Trust Technology.
"Specialization is for insects"
__________________________________________http://reality.sgi.com/offer/


Wed, 19 Nov 2003 01:59:17 GMT  
 Python equivilent to dlopen/dlsym ?

Quote:

> 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.

You may use __import__() to dynamically load a named module,
and getattr() to obtain the named attribute from the module
object (or the functions in standard module imp, if you need finer
control, but __import__/getattr may mimic well the dlopen/dlsym
distinction you need to prototype).

Alex



Wed, 19 Nov 2003 03:55:44 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. some undefined references in tclLoadDl.o (dlopen, dlsym) while linking with libtcl7.6a

2. customized Tcl_Main does not link dlopen, dlerror, dlsym

3. dlerror, dlopen and dlsym missing when I compile a little C program

4. dlerror/dlopen/dlsym link errors.

5. Python equivilent of pack()?

6. Equivilent to COBOL DISPLAY Verb

7. TCL equivilent of UNIX selec command

8. run cobol shared object using dlsym on AIX4.2 then SIGSEGV

9. Elk 2.2 on Solaris 2.3 - dlopen problems

10. Question about compiled moduls and dlopen

11. Announce: Ogg/Vorbis and Ao bindings (need help with dlopen)

12. ImportError: dlopen: cannot load expectmodule.so

 

 
Powered by phpBB® Forum Software