In this section, we will explore the usage of the standard read–eval–print loop (REPL) tool for Python inside Visual Studio. As mentioned in the introduction, PTVS has an enhanced version of REPL. Besides the standard Python commands in the REPL version of PTVS—the Interactive Python window—there are some added commands and functionalities that can help speed up the debugging process and also enable simple testing of your code.
The enhanced commands are shown by typing $help
in REPL, as shown in the following screenshot:
We'll go into detail on the most used and interesting commands. The $cls
command cleans up the command line, while the $reset
command cleans up the engine in a way that you can restart with a clean REPL environment.
The most interesting functions are $load
and $mod
. The $load
command permits you to execute the content of a given Python file inside REPL: