[Python-Dev] Python install layout and the PATH on win32

"Martin v. Löwis" martin at v.loewis.de
Tue Mar 20 17:19:55 CET 2012


> 1. Run python from the start menu.
> - Import sys, fiddle with sys.path to add my module, import/run my
> module, do my tests. When you exit /hard error out, the python window
> disappears.
> 
> 2. Double-click the .py file
> - Runs the file, but then disappears immediately (unless you put in
> something like input/raw_input just to keep the window open) - and if it
> errors out, you never see the traceback - it disappears too fast.
> 
> 3. Get a shell and run python.
> This requires cd'ing to the directory where my .py file is, but then I
> run/import it and I see the information. To repeat the process, either
> type python again or just press arrow-up.
> 
> 4. (Not relevant here) - do it in an IDE that does #3 for you.
> 
> #3 is the only reasonable way to do development if you are not in an IDE.

No - there is an version #3a:

3.a) Get a shell and run the script
CD into the directory, then directly run foo.py, without prefixing it
with python.exe.

This doesn't require any changes to the path, and is shorter in usage
than having the path specified.

With PEP 397, you will be able to run "py foo.py" without path
modification, and it will get the correct Python version even (which
neither the path manipulation nor the file association could achieve).

Regards,
Martin


More information about the Python-Dev mailing list