Windows Explorer Integration

If you open the Windows Explorer after installing Python, you might notice that all .py and .pyc files have their own cute Python icon! If you right-click on a .py file, notice the default menu entry is Run; you can select this entry from the menu or double-click on the .py file to run the program using the standard Python.exe. It’s possible that other Python extensions will install new items in this menu; for example, PythonWin (discussed later in this chapter) adds an Edit item, allowing you to open the Python source file for editing.

In addition, you can drag these .py files to your favorite text editor (including PythonWin) for editing. This can be any editor of your choice, or even the standard Windows notepad tool.[2]

Running Python programs from the Windows Explorer has one major problem: a new window is created for the Python program, and when it terminates, the window closes immediately. This means that any messages displayed by the program (either informational or error messages) usually vanish just as you are trying to read them. For this reason, most Windows users don’t execute their Python programs in this manner; they do so either from the Windows command prompt or from a Python integrated development environment (IDE), such as PythonWin or IDLE.

[2] Many standard Python library files are supplied with Unix-style line terminators. notepad is still one of the few Windows editors unable to cope with files of this format. For this and other ...

Get Python Programming On Win32 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.