Dec-05-2018, 06:04 PM
(This post was last modified: Dec-05-2018, 06:05 PM by Gribouillis.)
Python imports modules. It means that when you write
from one.sample1 import *
, there is an importable module or package named one
. Here are a few ways to achieve this:- Move the 'one' directory in 'two'. It will become importable in 'sample.py'
- Put the directory containing 'one' on the python path by manipulating the python path through the PYTHONPATH environment variable or the files usercustomize.py or sitecustomize.py
- Manipulate
sys.path
in 'sample.py' to make sure it contains the directory containing 'one'.
from ..one.sample1 import *
in 'sample.py' and invoke the script with the command python -m parent.two.sample
.