faqts : Computers : Programming : Languages : Python : Common Problems : C/C++ Code

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 5 people (60%) answered Yes
Recently 1 of 3 people (33%) answered Yes

Entry

I am writing a C++ program with embedded python. How can I redirect import commands to read the file from a different source, possibly not a true file at all but an entry in a zip file?

Jun 4th, 2000 04:39
unknown unknown, Michael Hudson


I don't know if being embedded offers other ways of doing this, but in
Python code (which should work here), you'd probably want to use Greg 
Stein's imputil.py:

   http://www.lyra.org/greg/python/

If you want to override *all* import unconditionally, you can assign
to __builtin__.__import__, but that requires a certain amount of Python 
internals knowledge.