howto get function from module, known by string names?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon May 21 09:58:31 EDT 2007


En Mon, 21 May 2007 10:13:02 -0300, dmitrey <openopt at ukr.net> escribió:

> And howto check does module 'asdf' exist (is available for import) or
> no? (without try/cache of course)

What's wrong with this:

try: import asdf
except ImportError: asdf = None

...later...

if asdf:
     asdf.zxcv(1)
     ...

-- 
Gabriel Genellina




More information about the Python-list mailing list