PyCharm 2024.1 Help

Watches

In the Watches pane you can evaluate any number of variables or expressions in the context of the current stack frame. The values are updated with each step through the application, and become visible every time the application is suspended.

Debug tool window

While the Evaluate Expression command from the context menu of the Variables pane enables you to see one expression at a time, the Watches pane shows multiple expressions that persist from one debug session to another, until you remove them.

You can create watches in this pane, in the Variables pane, and also in the editor.

Watch expressions are always evaluated in the context of a stack frame that is currently inspected in the Frames pane. If an expression cannot be evaluated, it is displayed with a question mark.

Open the Watches pane

By default, the Watches pane is hidden and the watches are shown in the Variables pane.

  • To have the Watches pane displayed separately and view the configured watches in it, click Layout Settings Layout Settings on the debugger toolbar and select Separate Watches.

Evaluate expression field

  1. To evaluate an arbitrary expression, enter it in the Evaluate expression field in the Watches pane and press Enter

  2. The result is displayed right below. You can also add the expression to watches by clicking in the right-hand part of the expression field.

    Result of an expression in the Variables tab

Toolbar

Item

Shortcut

Description

New Watch Button

Insert

Click this button to create a new watch.

Remove Watch button

Delete

Click this button to remove the selected watch from the list.

Move Watch Up button Move Watch Down button

Alt+UpAlt+Down

Use these buttons to change the order of watches.

Duplicate Watch button

Ctrl+D

Use this button to create a copy of the selected watch.

Show watches in Variables tab

Show watches in Variables tab

Use this toggle button to have the Watches pane hidden or shown. By default, the button is pressed and displayed on the toolbar of the Variables pane. Consequently, the Watches pane is hidden and the watches are shown in the Variables pane.

  • To have the Watches pane displayed separately and view the configured watches in it, release the Show watches in Variables tab toggle button. The Watches pane appears with the Show watches in Variables tab toggle button on the toolbar.

  • To hide the Watches pane and view the watches in the Variables pane, press the Show watches in Variables tab toggle button on the toolbar of the Watches pane. The toggle button returns to the default location on the toolbar of the Variables pane.

Item

Shortcut

Description

New Watch

Choose this command to create a new watch. A text field opens, where you can enter new watch expression.

Remove Watch

Delete

Choose this command to delete the currently selected watch expression from the list.

Edit

F2

Choose this command to change the selected watch expression.

Remove All Watches

Choose this command to delete all watch expressions from the list.

Inspect

This command is available for fields, local variables and reference expressions, and opens a non-modal Inspection window, where you can concentrate on a particular reference. You can open as many Inspection windows as required. The view in the Inspection window is the same as in the Watches pane, but requires less screen space.

Choose this command to display the list of objects referring to the current watch.

Copy Value

Ctrl+C

Use this command to copy the value of the selected variable to the Clipboard. If multiple items are selected, not only variables' values, but also their structure is copied, so that when you copy-paste the selection to a text file, the indentation mimics the tree output of the debugger to produce an easy-to-read output.

Alternatively, hover over a value and view its contents in the tooltip.

Copy JSON

This menu item is available only in the JavaScript context. Choose this command to copy the selected value in the JSON format.

Compare Value with Clipboard

Use this command to compare the selected value with the value currently in the Clipboard.

Copy Name

Use this command to copy the name of the selected variable to the Clipboard.

Evaluate Expression

Alt+F8

Use this command to evaluate the selected variable in the dialog that opens.

Add to Watches

This command is available for all nodes except static ones. Use this command to create an expression that references the node and add this expression to the Watches pane.

Show Referring Objects

Use this command to display a list of objects referring to the currently selected variable.

Jump to Source

F4

This command opens the source code of the selected variable or field in the editor and places the caret at the corresponding line.

Jump to Type Source

F4

Use this command to navigate to the definition of the class of the selected variable or field.

View as

Use this command to select how you want variable values to be displayed. For integer values, you can choose between binary, decimal, and hexadecimal formats.

  • Hex: this option is available for numeric variables. If selected, the variable is shown in the hexadecimal format.

  • Binary: this option is available for binary data. If selected, the variable is shown as a binary literal.

View as Array

This command is available for variables that represent NumPy arrays.

Note that NumPy must be installed in your Python interpreter.

You can also click the View as Array link next to the variable.

View as DataFrame

This command is available for variables that represent pandas data frames.

Note that pandas must be installed in your Python interpreter.

You can also click the View as DataFrame link next to the variable .

Last modified: 11 February 2024