Command-Line Parameters

PythonWin supports a number of command-line parameters as shown in this table.

Command Line

Description

/edit filename

Starts PythonWin and opens the named file for editing.

/run filename

Starts PythonWin and runs the specified script.

/nodde

Must be the first parameter. Starts PythonWin without DDE support, allowing for multiple PythonWin instances.

/app appmodule

Treats the named file as a PythonWin application. This is for advanced users only and is discussed in Chapter 20.

By default, PythonWin allows only one instance to be open. If you attempt to start a new instance of PythonWin, the existing instance is reused, primarily to support better integration with Windows Explorer, as described later in this chapter. PythonWin uses Dynamic Data Exchange (DDE) to communicate between instances, so the /nodde parameter can disable this behavior and allow as many PythonWin instances as you care to start.

To demonstrate these command lines, close the source file pywindemo.py (leave PythonWin running) and start a command prompt window. Enter the command:

C:\Somewhere> start pythonwin.exe /edit C:\Scripts\pywindemo.py

You should see your existing PythonWin application come to the foreground, and see pywindemo.py opened for editing. Switch back to the command prompt and enter the command:

C:\Somewhere> start pythonwin.exe /run c:\Scripts\pywindemo.py

You should see the same messages printed as when you ran the script directly from PythonWin. Finally, ...

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.