dynamic-import

Is it reasonable to save data as python modules?

This is what I've done for a project. I have a few data structures that are bascially dictionaries with some methods that operate on the data. When I save them to disk, I write them out to .py files as code that when imported as a module will load the same data into such a data structure. Is this reasonable? Are there any big disadvanta...

Load different modules without changing the logic file

Hi All: Suppose I've got 2 different modules which have the uniform(same) interfaces. The files list like this: root/ logic.py sns_api/ __init__.py facebook/ pyfacebook.py __init__.py myspace/ pymyspace.py __init__.py And pyfacebook.py and pymyspace.py have the same inte...

Dynamically importing Python module

I have a trusted remote server that stores many custom Python modules. I can fetch them via HTTP (e.g. using urllib2.urlopen) as text/plain, but I cannot save the fetched module code to the local hard disk. How can I import the code as a fully operable Python module, including its global variables and imports? I suppose I have to use som...