Warning
This page is located in archive.

Python on MS Windows

Seeing how MS Windows does not have the traditional strong shell of the unix based OSes (Linux, BSD, Solaris, OS X etc), there is some setting up to be done. This will make it so that .py files open in debugger, instead of just running.

Running .py files

If you are using Windows XP, then you have to go My Computer → Tools → Folder Options → File Types, find py, choose advanced and actions, then add the following.

DrPython

"C:\Program Files\Python26\pythonw.exe" "C:\Program Files\DrPython\drpython.py" "%1"

IDLE

"C:\Program Files\Python26\pythonw.exe" "C:\Program Files\Python26\Lib\idlelib\idle.py" "%1"

Python only

"C:\Program Files\Python26\pythonw.exe" "-i" "%1"

The -i parameter stops the window from closing after finished the program or if there is an error.

If you are using Windows 7, then you cannot assign an action to file extension. Easy workaround is to use a batch file with the above line and assign it to the .py file extension.

From the above, you can also easily derive how to use other editors for .py files.

DrPython

Basic controls:

  • F7 starts Python shell.
  • Ctrl-E (Execute) starts the written code.
  • F6 shows prompt, where you can see output of your code.

IDLE

After installing Python, you should have two links in your Start menu. IDLE (Python GUI) a Python(command line). IDLE (Integrated DeveLopment Environment) is a Python based Python editor integrated in Python installation. For script writing, use Ctrl+N (File - New Window).

Unless you use the above “fix” for startup, it gets started with the -n parameter (run IDLE without a subprocess), which can cause problems when some old modules remain in memory. The best solution is to kill the Python shell with Ctrl+D and then run the new program. If run through Start menu or desktop shortcut, this problem is mitigated. You can tell the difference, by looking at the process menu, in standart mode, one of the dropdown menus should be Shell. You can force shell restart through Ctrl+F6

IDLE tutorial

courses/ae4b99rph/tutorials/python/mswin.txt · Last modified: 2013/10/04 13:02 (external edit)