python __import__ question

Ben Finney bignose+hates-spam at benfinney.id.au
Thu May 25 07:15:11 CEST 2006


Evgeniy Zamriy <codebuger at gmail.com> writes:

> I have this code:
>   try:
>       empty_mod = __import__(some_empty_module)
>   except ImportError:
>       print "test"
>       raise
> 
> But python doesn't work with this except:
>     ImportError: No module named ....

Your example is incomplete.

    >>> try:
    ...     empty_mod = __import__(some_empty_module)
    ... except ImportError:
    ...     print "test"
    ...     raise
    ...
    Traceback (most recent call last):
      File "<stdin>", line 2, in ?
    NameError: name 'some_empty_module' is not defined

Can you post a minimal, complete example that shows the behaviour?

-- 
 \     "As we enjoy great advantages from the inventions of others, we |
  `\     should be glad to serve others by any invention of ours."  -- |
_o__)                                                Benjamin Franklin |
Ben Finney




More information about the Python-list mailing list