How do I edit a PythonWin path to import custom built modules???

Gabriel Genellina gagsl-py at yahoo.com.ar
Fri Dec 15 05:03:47 EST 2006


At Friday 15/12/2006 06:46, mohan wrote:

>To revert back to my question, I wanted to add a new path to my
>PythonWin IDE to access modules which are in folders other than normal
>python paths.  Here, I need to put my modules in different folders
>since it is a request of the user. I tried to create a new PYTHONPATH
>in the environmental variables section, which did not work .

You can do that directly inside PythonWin, using the Tools menu.

>So, is there any way where I can temporarily append the new path/s,
>where the PythonWin interpreter would look during run time and discard
>after the interpreter is closed.

You could modify sys.path at runtime, appending directories if 
needed. But the package solution below is much better.

>For example, my main program "ATS.py" will be put in the folder
>D:\\dSPACE\ATS\ and my modules will be put in other folders inside the
>folder ATS, D:\\dSPACE\ATS\ Level Regulation, D:\\dSPACE\ATS\ Curve
>Detection and so on.
>
>So, I would like to tell the interpreter to look in to these folders to
>import the modules.

First, remove all spaces from directory names. Then make them normal 
packages (an empty __init__.py may be enough) so you can write, in ATS.py:

from LevelRegulation import whatever
from CurveDetection.MyModuleName import MyClass

etc.


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list