Query about the __import__ function
both the imports were fine but, when i did this
my python version
Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
why is that am not able to import ?.
Code:
~pwd
/home/preyan/test
~ls
sample.py
~python
>>> mod=__import__('sample')
>>> amod=__import__('/home/preyan/test/sample')
>>>
Code:
# /home/preyan/mypro.py
mod='sample'
os.chdir('/home/preyan/test')
module=__import__(mod)
Traceback (most recent call last):
File "/home/preyan/mypro.py", line 3, in <module>
module=__import__(mod)
ImportError: No module named sample
Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
why is that am not able to import ?.
Comment