Python Shell
The Python Shell is the interpreter that executes your Python programs, other pieces of Python code, or simple commands.
Python code
|
Simple commands
|
Adding a Python Shell page
To add a new Python Shell page in the current problem, press b and select Add Python > Shell.
The Python Shell can also be launched from the Python Editor by executing a program by pressing b and selecting Run > Run.
Working in the Python Shell
Pressing b displays the Document Tools menu. With these menu options you can add, move, and copy blocks of code.
Document Tools menu
|
|
Note: If you use any method from one of the available modules, be sure to execute an import module statement first as in any Python coding environment.
Interaction with the Shell output is similar to the Calculator app where you can select and copy previous inputs and outputs for use elsewhere in the Shell, Editor, or other apps.
Up arrow to select, then copy and paste to the desired location
Global functions and variables from the last run program can be inserted by pressing h or /+L and selecting from the list or press b and select Variables > Vars: Last Run Program.
To choose from a list of global functions and variables from both the last run program and any imported modules, press b and select Variables > Vars: All.
Variables menu
|
||
Last Run Program variables
|
All variables
|
All Python Shell pages in the same problem share the same state (user-defined and imported variable definitions). When you save or run a Python program in that problem, or press b and select Tools > Reinitialize Shell, the Shell history will then have a gray background indicating that the previous state is no longer valid.
Before saving or reinitializing
|
After saving or reinitializing
|
Note: The b Tools > Clear History option clears the screen of any previous activity in the Shell, but variables are still available.
Messages
Error and other informational messages may display while you are in a Python session. If an error is displayed in the Shell when a program executes, a program line number will display. Press / b and select Go to Python Editor. In the Editor, press b then select Edit > Go to Line. Enter the line number and press ·. The cursor will display on the first character of the line where the error occurred.
Interrupting a Running Program
While a program or function is running, the busy pointer } is displayed.
▶ | To stop the program or function, |
- | Windows®: Press the F12 key. |
- | Mac®: Press the F5 key. |
- | Handheld: Press the c key. |