VisualStudio20132015 and PythonToolsforVisualStudio enable Visual Studio to provide a highly integrated development environment for the Python programming language, and give full play to the powerful functions of Visual Studio, helping you develop Python programs in Visual Studio, improve development efficiency! The following describes six advantages of Visual Studio integrated development of Python programs. Visual Studio 2013/2015, coupled with the Python Tools for Visual Studio extension kit, enables Visual Studio to provide a highly integrated development environment for the Python programming language, and give full play to the powerful functions of Visual Studio, help you develop Python programs in Visual Studio to improve development efficiency!
The following describes the advantages and functions of Visual Studio integrated development of Python programs.
Integrate the Python Interpreter (Interpreter) & Interactive window (Interactive)
Integrate Python Virtual development Environment (Virtual Environment)
Integrate the Python Package Manager)
Full support for Python by intelliisense
Debugging)
Remote Debugging)
Integrate the Python Interpreter (Interpreter) & Interactive window (Interactive)
Visual Studio is highly integrated with the Python interpreter, allowing you to switch between different versions of the Python interpreter during development. In addition to switching to the Python version you are familiar with for development, this function also ensures that the compatibility of your program running in different Python versions is legal, for example, the print function in the code is valid in the Python 2.7 environment (the red arrow points to the global interpreter currently using Python 2.7 ).
If your system has a different version of the interpreter installed, it will be integrated into Visual Studio for you to choose from. If you install a non-preset path for the path of the literal interpreter, or want to customize the literal interpreter Library or the literal interpreter bit, you can also add a custom literal interpreter on Visual Studio.
Next, we will demonstrate how to switch to a different version of Python Environment. here we will take switching to Python 3.5 as an example.
In this case, Visual Studio automatically detects scripts that are not supported by the Environment version, and prompts the user with incorrect code snippets through the quotation marks, allowing the user to quickly find out incompatibility between different versions, for quick correction.
The Interactive window is provided to start different versions of Interactive windows in Visual Studio. just like what was previously done in the Python command column, this Interactive window provides you with preliminary writing and testing, and a simple execution environment that verifies your design ideas.
Integrate Python Virtual development Environment (Virtual Environment)
Visual Studio provides a complete Python virtual environment to provide independent Python execution environments for different projects, in this way, you can avoid sharing a global environment among multiple projects so that there are too many kits irrelevant to the project in the environment, increasing the complexity of the development environment. Alternatively, you can install suites of different versions in different environments to test whether there are any differences in the types of suites used in different versions.
For example, we create multiple virtual environments to install packages of different versions for compatibility testing. the created virtual environment can be provided to other projects later, reduce the time required for installation and environment creation.
When creating a virtual environment, you can generate the requirements file through other virtual environments or installed kits in the global environment. This file can be used as a reference for creating a new virtual environment later, provides a list of suites required to quickly set up a new virtual environment.
Integrate the Python Package Manager)
There are many useful third-party suites in Python that can be installed by the pip or easy_install Suite Administrator, allowing you to call the scripts in these suites in code to help you achieve your development goals more quickly. These suite administrators are highly integrated in Visual Studio, allowing you to install the suite simply without entering tedious instructions.
For example, you can right-click the Python environment in which the package is to be installed in the solution manager to view the options for installing the Python package.
Then, if you enter the name of the suite you want to install, you can also specify a version here, or if you do not specify a version, install the latest version of the suite. Note that if you use the easy_install option, the package you are about to install will not be integrated into the solution manager, as a result, Visual Studio cannot be used to fully manage these suites installed through easy_install.
Full support for Python by intelliisense
Visual Studio also provides intelliisense support for Python in languages such as C #, VB, and VC ++. for example: auxiliary functions such as listing object members, writing call parameters and return value information, quick consultation, and automatic text completion allow you to have more confidence and improve writing efficiency when writing objects or calling functions.
Displays the intelliisense function to help list the member content exposed in the object.
Displays information about the call parameters provided by the intelliisense function.
In addition, intelliisense provides quick actions. for example, if you type main and press "T", you can automatically complete the appropriate code section and related references.
Debugging)
Visual Studio supports the complete error detection function for Python. for example, when a program is executed, it can temporarily stop at a breakpoint. at this time, it can view or modify the region variables and call stacks for the current execution, in the error detection mode, you can use important functions that you are familiar with, so that you can easily and quickly master program execution.
In addition, Visual Studio supports the Mixed debugging Mode (Mixed-Mode debugging) for Python ), if your Python Code has Native Code that uses external Code such as C/C ++ and has the Native Code, you can merge the debugging mode. Similar to the common debugging mode, a language other than Python can still change its value at a breakpoint.
In the same way, you can freely jump to the call stacks of different codes in the mixed debugging mode for code and variable inspection.
Version control
Visual Studio integrates version control and supports version control between Git and Visual Studio Team Services, visual Studio allows you to directly submit, restore, compare, and view the code history of your Python project using version control without additional tools. common functions.
Remote Debugging)
Visual Studio supports remote debugging for Python programs. This Python suite allows you to connect to Python programs executed on different operating systems (such as Linux) using Visual Studio. This feature enables you to achieve consistent development experience and improve overall development efficiency during cross-platform development!
For example, if the Python program runs on a Linux Embedded Development Board and Visual Studio 2015 is run on Windows 10 on a personal computer, it allows you to remotely append the program to the sequence through the ptsealing kit, directly perform the troubleshooting mode as you are familiar with the Python program running on the Linux Embedded Development Board. It also provides complete debugging modes, such as area variable inspection and call stack analysis, to analyze and track programs.
Additional information:
PTVS film teaching course
Open source code-GitHub/Microsoft/PTVS
The above is how to better develop the six functions of Python on Visual Studio! For more information, see other related articles in the first PHP community!