Integrated Python Shell

Index of All Documentation » Wing Pro Reference Manual »


The integrated Python Shell is used to execute or debug commands and expressions interactively, in a way that is tightly integrated with Wing's editor, code inspection, and debugger features.

The Python Shell's auto-completer uses introspection of the runtime environment as a powerful way to find and inspect functionality and craft new code interactively. The Source Assistant in Wing Pro and Wing Personal displays documentation, call signature, and other information about symbols as you work in the Python Shell

Goto-definition will also work in the Python Shell, using a combination of runtime and static analysis to find the definition of the symbol or its type.

Evaluating Code from the Editor

There are several ways to evaluate code from an editor within the Python Shell:

Copy and Paste and Drag and Drop adjust leading indentation and execute the code.

Evaluate File in Python Shell in the Source menu restarts the Python Shell and then evaluates the top level of the current file. Restarting can be disabled by unchecking Auto-restart When Evaluate File in the Options menu at the top right of the tool. This operation sets the value of sys.argv to match the value that would be used if the file were debugged. If a launch configuration has been selected in the Python Shell's Options menu then its run arguments are used instead.

Evaluate Selection in Python Shell in the Source menu evaluates the current selection in the shell. This is also available in the editor's right-click context menu.

Set an Active Range from the editor into the Python Shell so it can be executed or debugged repeatedly during editing. See Active Ranges in the Python Shell for details.

The Options menu in the Python Shell tool also contains items for evaluating the current file or selection

To clear the shell's state at any time, use Restart Shell in the Options menu.

Debugging

Code entered into the Python Shell may be executed with or without debug. When debugging is enabled, execution will reach breakpoints, allow stepping through code, and support inspection of runtime state. See Debugging Code in the Python Shell for details.

In Wing Pro, the Debug Console can be used to interact in a similar way with the current frame of a debug process.

Command History

The Up and Down arrow keys traverse the history of the code you have entered and the Return key executes the code if it is complete, or prompts for another line if it is not. If Filter History by Entered Prefix in the Options``menu is checked then any text typed before pressing ``Up will be used to filter the history items that are traversed.

Code recalled from history can be edited within the Python Shell. Use Ctrl-Up and Ctrl-Down to move the caret up and down and Ctrl-Return to insert a new line at the caret position.

To save the contents of the shell, use Save a Copy in the Options menu or the tool's right-click context menu. The context menu also provides items for copying text from the shell, with or without prompts.

Section Contents