Interactive Python Shell
Wing provides an integrated Python Shell for execution of commands and experimental evaluation of expressions. The version of Python used in the Python Shell, and the environment it runs with, is configured in your project using Project Properties or by setting a particular launch configuration from the Options menu.
In Wing 101, Python environment is instead configured with Configure Python in the Edit menu.
This shell runs a separate Python process that is independent of the IDE and functions without regard to the state of any running debug process. In Wing Pro, the Debug Probe can be used to interact in a similar way with your debug process. For details see Interactive Debug Probe.
Convenient ways to run parts of your source code in the shell include:
Copy/Paste part of a file -- Wing will automatically adjust leading indentation so the code can be executed in the shell.
Drag and Drop part of a file -- This works like Copy/Paste.
Evaluate File in Python Shell -- This command in the Source menu will evaluate the top level of the current file in the shell.
Evaluate Selection in Python Shell -- The command in the Source menu and editor's context menu (right-click) will evaluate the current selection in the shell.
Set an Active Range -- (Wing Pro only) This is done with the icons in the top right of the Python Shell. By selecting a range in an editor and pressing the active range icon, Wing locks that range of code into the shell so it's easily re-executed after being edited.
The Options menu in the Python Shell tool -- This contains items for evaluating the current file or selection
In the Python Shell, the Up and Down arrow keys will traverse the history of the code you have entered and the return key will either execute the code if it is complete or prompt for another line if it is not. Ctrl-Up and Ctrl-Down will move the cursor up and down and Ctrl-Return will insert a new line character at the cursor position.
To restart the Python Shell, select Restart Shell from the Options menu in the top right of the tool. This will terminate the external Python process and restart it, clearing and resetting the state of the shell.
To save the contents of the shell, use Save a Copy in the Options menu or right-click context menu. The right-click context menu also provides items for copying and pasting text in the shell.
To preload some code into the Python Shell when it is started, you can set the PYTHONSTARTUP environment variable, as supported by the Python Shell outside of Wing.
9.1. Python Shell Auto-completion
9.2. Debugging Code in the Python Shell
9.3. Python Shell Options