python __import__ problem

Posted by Anurag Uniyal on Stack Overflow See other posts from Stack Overflow or by Anurag Uniyal
Published on 2009-06-29T11:35:00Z Indexed on 2010/05/09 20:08 UTC
Read the original article Hit count: 325

Filed under:
|

I have a messages folder(package) with __init__.py file and another module messages_en.py inside it. In __init__.py if I import messages_en it works, but __import__ fails with "ImportError: No module named messages_en"

import messages_en # it works
messages = __import__('messages_en') # it doesn't ?

I used to think 'import x' is just another way of saying __import__('x')

© Stack Overflow or respective owner

Related posts about python

Related posts about import