Conditional Import
Danil
danil at ultranet.com
Thu Mar 14 11:40:38 EST 2002
Is there a standard python idiom for coping with importing one of several
libraries?
Right now, I've this hack in the middle of my code
try:
from codeop import CommandCompiler
except:
from MockCommandCompiler import CommandCompiler
But if I have to put up with a work around like this, I'd prefer that it
be fairly elegant. Or at least standard...
Danil
p.s. because codeop.CommandCompiler fails in 2.1, and I've yet to find a
recipe that will get me to Win32 + Python 2.2 + pygtk. That help would
be appreciated too; I've been unable to find or build a _gtk.pyd that
python22 will import.
More information about the Python-list
mailing list