Visual Studio How to better develop the six major functions of Python on Visual Studio!0How to better develop the six major functions of Python on Visual Studio!How to better develop the six major functions of Python on Visual Studio!/How to better develop the six major functions of Python on Visual Studio!0How to better develop the six major functions of Python on Visual Studio!How to better develop the six major functions of Python on Visual Studio! with the Python Tools for Visual Studio extension kit allows Visual Studio to provide a highly integrated development environment for the Python programming language and fully utilize the powerful functions of Visual Studio to help you develop Python programs in Visual Studio even more powerfully and improve Development efficiency!
The following will describe six advantages of Visual Studio integrated development of Python programs.
Integrate Python interpreter (Interpreter) & interactive window (Interactive)
Integrate Python virtual development environment (Virtual Environment)
Integrate Python Package Manager
IntelliSense has complete support for Python
Using debugging mode with Python
Cross-platform remote debugging
Visual Studio is highly integrated with the Python interpreter, allowing you to switch between different versions of the Python interpreter during the development process. In addition to being able to switch to the Python version you are familiar with for development, this function can also ensure that the function compatibility of your program running under different Python versions is legal. For example, the print function in the code below is in Python. It is legal in the How to better develop the six major functions of Python on Visual Studio!.How to better develop the six major functions of Python on Visual Studio! environment (the red arrow points to the current use of the Python How to better develop the six major functions of Python on Visual Studio!.How to better develop the six major functions of Python on Visual Studio! global environment interpreter).
If your system has different versions of interpreters installed, they will be integrated into Visual Studio for you to choose from. If the path where you installed the interpreter is not the default path or you want to customize the interpreter library and interpreter bits, you can also add a custom interpreter in Visual Studio.
Next, we demonstrate switching to a different version of the Python environment. Here we take switching to Python How to better develop the six major functions of Python on Visual Studio!.How to better develop the six major functions of Python on Visual Studio! as an example.
At this time, you will find that Visual Studio automatically detects functions that are not supported by the environment version, and prompts the user with the wrong code fragment through quotation marks, allowing the user to quickly find incompatibilities between different versions for quick processing. Correction work.
It also provides the ability to launch different versions of the Interactive window in Visual Studio. Just like what you used to do under the Python command line, this interactive window provides you with a simple execution environment for preliminary writing, testing, and verification of your design ideas. .
Visual Studio provides a complete Python virtual environment to provide independent Python execution environments for different projects. This can avoid multiple projects sharing a global environment with too many packages that are not related to the project in the environment, increasing development The complexity of the environment. Or you can install different versions of the package in different environments to test whether the functions used in the package are different in different versions.
As shown in the figure below, we create multiple virtual environments to install different versions of packages for compatibility testing. The created virtual environments can be later used by other projects to reduce the redundant cost of installation and environment creation. setting time.
When creating a virtual environment, you can generate a requirements file through other virtual environments or installed packages in the global environment. This file will be used as a reference when creating a new virtual environment later, providing the information needed to quickly set up a new virtual environment. Kit list.
There are many useful third-party packages in Python that can be installed through pip or the easy_install package manager, allowing you to call functions in these packages in your code to help you achieve your development goals faster. These package administrators are highly integrated in Visual Studio, allowing you to easily install packages without entering cumbersome instructions.
As shown in the picture below, you can right-click the Python environment where you want to install the package in the solution manager to see the option to install the Python package.
Then enter the name of the package you want to install as shown below. Here you can also specify the version to install, or install the latest version of the package without specifying it. Also note that if you use the easy_install option, the packages you are about to install will not be integrated into the solution manager. As a result, you will not be able to use Visual Studio to fully manage these packages installed through easy_install.
For Python, Visual Studio also provides IntelliSense support for languages such as C#, VB, VC++, etc., such as: listing object members, function call parameters and return value information, quick consultation, automatic text completion and other auxiliary functions, allowing you to You can be more confident when writing objects or calling functions and improve writing efficiency.
The figure below shows the IntelliSense function to help list the member content exposed in the object.
The figure below shows the function call parameter information provided by the IntelliSense function.
In addition, IntelliSense provides quick actions, such as typing main and pressing "T" to automatically complete the appropriate code sections and related references for you.
Visual Studio supports complete debugging capabilities for Python. For example, you can pause at the interruption point during program execution. At this time, you can view or modify local variables and call stacks of the current execution, and you can use familiar tools in debug mode. Important functions allow you to grasp program execution more easily and quickly.
In addition, Visual Studio supports Mixed-Mode debugging for Python. If your Python code uses external Native Code such as C/C++ and you have the source code project of the Native Code, you can do it. Mixed debugging mode. As with general debugging mode, languages other than Python can still enter break points and change their variable values.
Similarly, you can also freely jump to call stacks of different codes to browse codes and variables in mixed debugging mode.
Visual Studio integrates version control, which supports Git and Visual Studio Team Services version control. Through Visual Studio, you can now directly submit, restore, compare, and review code on your Python project in Visual Studio without additional tools. Common functions used in version control such as history records.
Visual Studio has added remote debugging capabilities to Python programs. Through this Python suite, you can use Visual Studio to connect to Python programs running on different operating systems (such as Linux). This feature enables you to obtain a more consistent development experience and improve overall development efficiency when developing across platforms!
As shown in the figure below, the Python program is running on a Linux embedded development board. At the same time, Visual Studio How to better develop the six major functions of Python on Visual Studio!0How to better develop the six major functions of Python on Visual Studio!How to better develop the six major functions of Python on Visual Studio! is running on Windows How to better develop the six major functions of Python on Visual Studio!0 on a personal computer. Through the ptvsd package, you can remotely attach to the program and directly connect to the Linux embedded development board. Run the Python program in debugging mode as you are familiar with. It also retains complete debugging mode functions such as area variable inspection, call stack analysis and other complete debugging functions for program analysis and tracking.
References:
PTVS video teaching course
Open source code – GitHub/Microsoft/PTVS
The above is the detailed content of How to better develop the six major functions of Python on Visual Studio!. For more information, please follow other related articles on the PHP Chinese website!