Le 12/07/2015 06:02, Ernest Bonat, Ph.D. a écrit :
Thanks for your help. I had follow the link: How to add a Python module
to syspath?
<http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath>
and I could not make it work. I did use sys.path.insert() and
sys.path.append() as:
Examples: sys.path.append('/python_mvc_calculator/calculator/') or
sys.path.insert(0, "/python_mvc_calculator/calculator")
I did try it to:
sys.path.append('/python_mvc_calculator/calculator/controller') or
sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too!
The main.py file is in python_mvc_calculator/calculator folder and I
need to import a module calculatorcontroller.py in
"python_mvc_calculator/calculator/controller"
I hope this explanation helps a bit!
<http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath>
Thanks
If "/python_mvc_calculator/calculator/controller" is a folder and if you
have a file __init__.py into this folder, you have to use:
sys.path.insert(0, "/python_mvc_calculator/calculator/controller")
from calculatorcontroller import foo # or import calculatorcontroller
But the init file must be named __init__.py NOT init.py as sayed in
askubuntu.
Vincent
--
https://mail.python.org/mailman/listinfo/python-list