Running external module and accessing the created objects
rosuav at gmail.com
Sat Mar 9 12:47:52 CET 2013
On Sat, Mar 9, 2013 at 10:05 PM, Kene Meniru <Kene.Meniru at illom.org> wrote:
> I have tried importing "user.py" and/or "app.py". However there is no
> single command to call.
I haven't followed the thread in detail, but I gather you're trying to
import a file with a variable name? Instead of 'import user', try:
user = __import__("foobar")
You can then replace the quoted string with whatever you need (note,
leave off the .py extension). In your code, it'll be as if you did:
import foobar as user
but with the flexibility of using whatever run-time-chosen name you need.
More information about the Python-list