469,281 Members | 2,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

python __import__ question


Hello, All:

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 ....

My python version is 2.4.2 (Linux)

Thanks for your replies....
May 25 '06 #1
1 2406
Evgeniy Zamriy <co*******@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

May 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by Simon Wittber | last post: by
4 posts views Thread by Nicolas Fleury | last post: by
reply views Thread by rmm | last post: by
1 post views Thread by Robin Becker | last post: by
24 posts views Thread by Mark | last post: by
reply views Thread by Lie | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.