Home > Backend Development > Python Tutorial > Useful Python plug-ins and configurations under VSCode_python

Useful Python plug-ins and configurations under VSCode_python

不言
Release: 2018-04-08 11:01:17
Original
11320 people have browsed it

This article mainly introduces Microsoft’s official Python plug-in, which already has many functions. The following is a description of the plug-in function. I have translated some of the content. Friends who need it can refer to it

MS Python plugin.

This is Microsoft’s official Python plug-in, which already comes with many functions. The following is a description of the plug-in function, part of which I have translated.

a) Linting (Prospector, Pylint, pycodestyle, Flake8, pylama, pydocstyle, mypy with config files and plugins) static code scanning (can be understood as code syntax and format error prompts, supports multiple linters)

b)                                                                                                                                                                out out out                                out off        , ,         out    ,, ,   Over to be in the 10-year-old's 3-year-old's 3-year-old's

d) Code formatting (autopep8, yapf, with config files) Code automatic formatting

e) Code refactoring (Rename, Extract Variable, Extract Method, Sort Imports)Code refactoring (Rename, Extract Variable, Extract Method, Sort Imports) Named, extracted variables, extraction methods, sorting it)

F) Viewing References, Code Navigation, View Signature View quotation, code navigation, check the signature

## ste) Excellent Debugging (Remote Deb ugging Over SSH, Mutliple Threads, Django, Flask) Perfect debug support (via SSH remote debugging, multi -thread, Django, Flask)

## h) Running and debugging unit tests (Unittest, Pytest, NOTESE, WIT h config files ) Run and debug unit tests

i)                                                                                                       Execute file or code in a python terminal                    Yes, basic needs are met. For example, if you want to automatically format the code, you only need to press Alt+Shift+F, and vscode will call autopep8 to automatically format the code (off topic, Visual Studio is Ctrl+K, D).

But we are not satisfied with this, we want to realize our own style. For example, Snippets, if we enter for, select the corresponding snippet in the prompt box:

Click Enter or tab, it becomes:

for target_list in expression_list:
  pass
Copy after login

If we want to define our own Snippets, for example, if we want to quickly enter for xx in enumerator() to traverse, what should we do? First open File-Preferences-User Code Snippets. vscode will prompt you to select the language. We enter Python and press Enter to open python.json. The content format is json. Add a new object of your own below the root level. The content is as follows:

"For in enumerator": {
    "prefix": "for/enum",
    "body": [
      "for ${1:index}, ${2:item} in enumerate(${3:array}):",
      "  ${4:pass}"
    ],
    "description": "For statement with enumerator"
  }
Copy after login

In this way, after we enter for/enum and press Enter , it is automatically generated:

for index, item in enumerate(array):
  pass
Copy after login

The cursor stays on index and selects the word. We can directly modify it, press tab to switch to item, and then array , pass.

Guides: Indentation Tips

Some people say that there are already indentation reference lines in vscode, what else do you need Guides for? Indeed, vscode has indentation lines, but this Guide is better than the built-in indentation line. Please see the picture below:

The current level indentation line will change. Red, it is clear which level you are currently at.

vscode-icons file icon set, supports more file types, and most importantly, looks better!

About automatically pausing during debugging in the first sentence.

It can be configured here, that is, in the lauch.json file, there is "stopOnEntry": true. If it is set to false, it will no longer pause.

Others

There are also some python plug-in configurations, which I won’t go into detail one by one. You can search them in the settings (File-Preferences-Settings). Includes:

a) autopep8/yapf: automatically formats code;

b) pylint-django: compatible with pylint of Django, requires pip install; c) flakes8 :Error message.

Hope you all have a good time~

Related recommendations:

How to configure the python debugging runtime environment under VSCode_python

The above is the detailed content of Useful Python plug-ins and configurations under VSCode_python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template