python __import__ question

E

Evgeniy Zamriy

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

Ben Finney

Evgeniy Zamriy said:
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.
... 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?
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top