Skip to content

Commit 10a6c87

Browse files
authored
Merge pull request #9480 from MicrosoftDocs/main638264414988263287sync_temp
Repo sync for protected CLA branch
2 parents b376374 + 9b82ac4 commit 10a6c87

23 files changed

+106
-112
lines changed

docs/debugger/toc.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
href: getting-started-with-the-debugger-cpp.md
2727
- name: Learn to debug Visual Basic
2828
href: ../get-started/visual-basic/tutorial-debugger.md?toc=%2fvisualstudio%2fdebugger%2ftoc.json
29-
- name: Running Python code in the debugger...
29+
- name: Running Python code in the debugger >>
3030
href: ../python/tutorial-working-with-python-in-visual-studio-step-04-debugging.md
3131
- name: Debug a live Azure app
3232
href: debug-live-azure-applications.md
@@ -424,13 +424,13 @@
424424
href: ../xaml-tools/debug-xaml-in-blend.md
425425
- name: How to trigger suspend, resume, and background events
426426
href: how-to-trigger-suspend-resume-and-background-events-for-windows-store-apps-in-visual-studio.md
427-
- name: Managed code (C#, Visual Basic, F#)
427+
- name: .NET
428428
items:
429429
- name: Debugging preparation
430430
items:
431-
- name: 'Debugging preparation: C#, F#, and Visual Basic project types'
431+
- name: 'Debugging preparation: .NET'
432432
href: debugging-preparation-csharp-f-hash-and-visual-basic-project-types.md
433-
- name: 'Managed debugging: Recommended property settings'
433+
- name: Recommended property settings
434434
href: managed-debugging-recommended-property-settings.md
435435
- name: 'Debugging preparation: Windows Forms applications'
436436
href: debugging-preparation-windows-forms-applications.md
@@ -492,10 +492,8 @@
492492
href: mfc-debugging-techniques.md
493493
- name: CRT debugging techniques >>
494494
href: /cpp/c-runtime-library/crt-debugging-techniques
495-
- name: Native code debugging FAQs
496-
items:
497-
- name: Debugging native code FAQs
498-
href: debugging-native-code-faqs.yml
495+
- name: FAQ for debugging native code
496+
href: debugging-native-code-faqs.yml
499497
- name: COM
500498
items:
501499
- name: COM server and container debugging

docs/python/debugging-python-in-visual-studio.md

Lines changed: 54 additions & 52 deletions
Large diffs are not rendered by default.
22.3 KB
Loading
Loading
Loading
25.7 KB
Loading
17.3 KB
Loading
27.5 KB
Loading
25 KB
Loading
7.24 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
6.17 KB
Loading
15 KB
Loading
3.71 KB
Loading
11.8 KB
Loading
Loading

docs/python/python-interactive-repl-in-visual-studio.md

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Python interactive window (REPL)
33
description: Use the interactive window (REPL) for rapid Python code development in Visual Studio.
4-
ms.date: 02/06/2022
4+
ms.date: 07/28/2023
55
ms.topic: how-to
66
author: cwebster-99
77
ms.author: cowebster
@@ -12,22 +12,23 @@ ms.workload:
1212
- python
1313
- data-science
1414
---
15+
1516
# Work with the Python Interactive window
1617

17-
[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]
18+
[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]
1819

19-
Visual Studio provides an interactive read-evaluate-print loop (REPL) window for each of your Python environments, which improves upon the REPL you get with *python.exe* on the command line. The **Interactive** window (opened with the **View** > **Other Windows** > **<environment> Interactive** menu commands) lets you enter arbitrary Python code and see immediate results. This way of coding helps you learn and experiment with APIs and libraries and interactively develop working code to include in your projects.
20+
Visual Studio provides an interactive read-evaluate-print loop (REPL) window for each of your Python environments, which improves upon the REPL you get with _python.exe_ on the command line. The **Interactive** window (opened with the **View** > **Other Windows** > **<environment> Interactive** menu commands) lets you enter arbitrary Python code and see immediate results. This way of coding helps you learn and experiment with APIs and libraries and interactively develop working code to include in your projects.
2021

2122
:::image type="content" source="media/interactive-window.png" alt-text="Screenshot showing the Python interactive read-evaluate-print loop (REPL) window.":::
2223

2324
Visual Studio has many Python REPL modes to choose from:
2425

25-
| REPL | Description | Editing | Debugging | Images |
26-
| --- | --- | --- | --- | --- |
27-
| Standard | Default REPL talks to Python directly | Standard editing (multiline, and so on). | Yes, via `$attach` | No |
28-
| Debug | Default REPL talks to debugged Python process | Standard editing | Only debugging | No |
29-
| IPython | REPL talks to IPython backend | IPython commands, Pylab conveniences | No | Yes, inline in REPL |
30-
| IPython w/o Pylab | REPL talks to IPython backend | Standard IPython | No | Yes, separate window |
26+
| REPL | Description | Editing | Debugging | Images |
27+
| ----------------- | --------------------------------------------- | ---------------------------------------- | ------------------ | -------------------- |
28+
| Standard | Default REPL talks to Python directly | Standard editing (multiline, and so on). | Yes, via `$attach` | No |
29+
| Debug | Default REPL talks to debugged Python process | Standard editing | Only debugging | No |
30+
| IPython | REPL talks to IPython backend | IPython commands, Pylab conveniences | No | Yes, inline in REPL |
31+
| IPython w/o Pylab | REPL talks to IPython backend | Standard IPython | No | Yes, separate window |
3132

3233
This article describes the **Standard** and **Debug** REPL modes. For details on IPython modes, see [Use the IPython REPL](interactive-repl-ipython.md).
3334

@@ -65,20 +66,20 @@ Once the **Interactive** window is open, you can start entering code line-by-lin
6566

6667
The exception is when more lines of code are needed to make a complete statement, such as when a `for` statement ends in a colon as shown above. In these cases, the line prompt changes to **...**, indicating that you need to enter more lines for the block, as shown on the fourth and fifth lines in the graphic above. When you press **Enter** on a blank line, the **Interactive** window closes the block and runs it in the interpreter.
6768

68-
> [!Tip]
69-
> The **Interactive** window improves upon the usual Python command-line REPL experience by automatically indenting statements that belong to a surrounding scope. Its history (recalled with the up arrow) also provides multiline items, whereas the command-line REPL provides only single lines.
70-
<a name="meta-commands"></a>
71-
The **Interactive** window also supports several meta-commands. All meta-commands start with `$`, and you can type `$help` to get a list of the meta-commands and `$help <command>` to get usage details for a specific command.
69+
> [!Tip]
70+
> The **Interactive** window improves upon the usual Python command-line REPL experience by automatically indenting statements that belong to a surrounding scope. Its history (recalled with the up arrow) also provides multiline items, whereas the command-line REPL provides only single lines.
71+
> <a name="meta-commands"></a>
72+
> The **Interactive** window also supports several meta-commands. All meta-commands start with `$`, and you can type `$help` to get a list of the meta-commands and `$help <command>` to get usage details for a specific command.
7273
73-
| Meta-command | Description |
74-
| --- | --- |
75-
| `$$` | Inserts a comment, which is helpful to comment code throughout your session. |
74+
| Meta-command | Description |
75+
| ---------------- | --------------------------------------------------------------------------------------- |
76+
| `$$` | Inserts a comment, which is helpful to comment code throughout your session. |
7677
| `$cls`, `$clear` | Clears the contents of the editor window, leaving history and execution context intact. |
77-
| `$help` | Display a list of commands, or help on a specific command. |
78-
| `$load` | Loads commands from file and executes until complete. |
79-
| `$mod` | Switches the current scope to the specified module name. |
80-
| `$reset` | Resets the execution environment to the initial state, but keeps history. |
81-
| `$wait` | Waits for at least the specified number of milliseconds. |
78+
| `$help` | Display a list of commands, or help on a specific command. |
79+
| `$load` | Loads commands from file and executes until complete. |
80+
| `$mod` | Switches the current scope to the specified module name. |
81+
| `$reset` | Resets the execution environment to the initial state, but keeps history. |
82+
| `$wait` | Waits for at least the specified number of milliseconds. |
8283

8384
Commands are also extensible by Visual Studio extensions by implementing and exporting `IInteractiveWindowCommand` ([example](https://github.com/Microsoft/PTVS/blob/master/Python/Product/PythonTools/PythonTools/Repl/InteractiveWindowCommands.cs#L85)).
8485

@@ -103,10 +104,11 @@ In addition to working within the **Interactive** window directly, you can selec
103104

104105
This command is useful for iterative or evolutionary code development, including testing your code as you develop it. For example, once you've sent a piece of code to the **Interactive** window and seen its output, you can press the up arrow to show the code again, modify it, and test it quickly by pressing **Ctrl**+**Enter**. (Pressing **Enter** at the end of input executes it, but pressing **Enter** in the middle of input inserts a newline.) Once you have the code you want, you can easily copy it back into your project file.
105106

106-
> [!Tip]
107-
> By default, Visual Studio removes **>>>** and **...** REPL prompts when pasting code from the **Interactive** window into the editor. You can change this behavior on the **Tools** > **Options** > **Text Editor** > **Python** > **Advanced** tab using the **Paste removes REPL prompts** option. See [Options - Miscellaneous options](python-support-options-and-settings-in-visual-studio.md#miscellaneous-options).
107+
> [!Tip]
108+
> By default, Visual Studio removes **>>>** and **...** REPL prompts when pasting code from the **Interactive** window into the editor. You can change this behavior on the **Tools** > **Options** > **Text Editor** > **Python** > **Advanced** tab using the **Paste removes REPL prompts** option. See [Options - Miscellaneous options](python-support-options-and-settings-in-visual-studio.md#miscellaneous-options).
108109
109110
<!-- After 15.3 is released, you can also press **Undo** after pasting to restore prompts. Press **Undo** a second time to remove the pasted code entirely. -->
111+
110112
:::moniker-end
111113

112114
:::moniker range=">=vs-2022"
@@ -116,21 +118,12 @@ In addition to working within the **Interactive** window directly, you can selec
116118

117119
This command is useful for iterative or evolutionary code development, including testing your code as you develop it. For example, once you've sent a piece of code to the **Interactive** window and seen its output, you can press the up arrow to show the code again, modify it, and test it quickly by pressing **Ctrl**+**E**. (Pressing **Enter** at the end of input executes it, but pressing **Enter** in the middle of input inserts a newline.) Once you have the code you want, you can easily copy it back into your project file.
118120

119-
> [!Tip]
120-
> By default, Visual Studio removes **>>>** and **...** REPL prompts when pasting code from the **Interactive** window into the editor. You can change this behavior on the **Tools** > **Options** > **Text Editor** > **Python** > **Advanced** tab using the **Paste removes REPL prompts** option. See [Options - Miscellaneous options](python-support-options-and-settings-in-visual-studio.md#miscellaneous-options).
121+
> [!Tip]
122+
> By default, Visual Studio removes **>>>** and **...** REPL prompts when pasting code from the **Interactive** window into the editor. You can change this behavior on the **Tools** > **Options** > **Text Editor** > **Python** > **Advanced** tab using the **Paste removes REPL prompts** option. See [Options - Miscellaneous options](python-support-options-and-settings-in-visual-studio.md#miscellaneous-options).
121123
122124
<!-- After 15.3 is released, you can also press **Undo** after pasting to restore prompts. Press **Undo** a second time to remove the pasted code entirely. -->
123-
:::moniker-end
124-
125-
## Work with code cells
126125

127-
Code cells can be used in data analysis and are supported by various text editors.
128-
129-
For example, when using a code file as a scratchpad, you often have a small block of code you want to send all at once. To group code together, mark the code as a *code cell* by adding a comment starting with `#%%` to the beginning of the cell, which ends the previous one. Code cells can be collapsed and expanded, and using **Ctrl**+**Enter** inside a code cell sends the entire cell to the **Interactive** window and moves to the next one.
130-
131-
Visual Studio also detects code cells starting with comments like `# In[1]:`, which is the format you get when exporting a Jupyter notebook as a Python file. This detection makes it easy to run a notebook from [Azure Notebooks](https://notebooks.azure.com/) by downloading it as a Python file, opening in Visual Studio, and using **Ctrl**+**Enter** to run each cell.
132-
133-
:::image type="content" source="media/interactive-code-cells.png" alt-text="Screenshot showing Interactive code cells.":::
126+
:::moniker-end
134127

135128
## IntelliSense behavior
136129

0 commit comments

Comments
 (0)