python script doesn't check cwd during import

Inyeol Lee inyeol_lee at yahoo.com
Wed May 29 18:16:51 EDT 2002


I'm using python2.2.1 on Solaris8.
When I launch a python script, it imports modules from the directory
where the script is, not from current directory. For example,

$ pwd
/home/inyeol/test/d
$ ls .
bar.py
$ cat bar.py
print "I'm bar"
$ ls ..
foo.py
$ cat ../foo.py
#!/usr/bin/env python
import bar
$ ../foo.py
Traceback (most recent call last):
  File "../foo.py", line 3, in ?
    import bar
ImportError: No module named bar
$ mv ./bar.py ..
$ ../foo.py
I'm bar
$

Is it a bug or a feature?

Inyeol...



More information about the Python-list mailing list