M
MindClass
Is possible import a library according to a condition?
if Foo = True:
import bar
if Foo = True:
import bar
MindClass said:Is possible import a library according to a condition?
if Foo = True:
import bar
I thinked that could be another way for import statement.Georg said:Why don't you try it?
MindClass said:I thinked that could be another way for import statement.
In that case I'll have to set a global variable before of the import
statements although I'd prefer not use them.
The problem is that I've to import different libraries according to theSteve said:I'm guessing that you think this might be necessary to avoid importing
the same module multiple times: it's not. Python only runs the module's
code the first time the module is imported into a program. A further
import statement effectively does noting, because the interpreter sees
(from an entry in the sys.modules dictionary) that the module is already
present.
So why the need for global variables?MindClass said:The problem is that I've to import different libraries according to the
ORM (SQLObject, SQLAlchemy, etc)
Did you even try ? Would have been faster than posting here...MindClass said:Is possible import a library according to a condition?
if Foo = True:
import bar
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.