: :
~/test/kl% ls -R
.:
foo spam.py
./foo:
eggs.py eggs.pyc ham.py ham.pyc __init__.py __init__.pyc
:
~/test/kl% cat spam.py
import foo.eggs
~/test/kl% cd foo/
~/test/kl/foo% cat eggs.py
print( "got eggs, importing ham!" )
import ham
spam.py foo/eggs.py:
~/test/kl% python spam.py
got eggs, importing ham!
got ham!
, python script.py, , script.py, sys.path, . python spam.py PYTHONPATH.
~/test/kl% python foo/eggs.py
got eggs, importing ham!
got ham!
~/test/kl/foo sys.path. , eggs.py import ham. ham.py ~/test/kl/foo, sys.path, Python .
~/test/kl% cd foo
~/test/kl/foo% python eggs.py
got eggs, importing ham!
got ham!
~/test/kl PYTHONPATH.