Python code specification tool Flake8

Source: Internet
Author: User
The Python code specification tool Flake8 requires code writing, especially in the team; otherwise, Google will not release various coding specifications, which are familiar with Google C ++ style guidelines, google Python style guide.

Are these specifications useful? It is useful and useless. unless you have a good mind, you need to coding and use the specifications. Otherwise, we still need a tool to do this. Fortunately, there are more than one python tool to help us do this. Let's get off your feet and get started.

Pylint

I have used it, and it turns purple. I don't know who is so boring. can we make pythoner so happy when the rules are set so dead? We don't see rubyer. what does Matz advocate? Happy Coding? So I still use it, because I don't need to be so crazy ~ If you want to install it, it is also simple:

Easy_install pylint // maybe nedd root

Pep8

As the name suggests, it comes from the famous PEP 8 in the Python community. Basically, this is the right way to write code, but this is not perfect. the installation is as follows:

Easy_install pep8 // maybe nedd root


Pyflakes


The Python program passive detection tool is really passive enough. according to the author, it is fast and not powerful enough, but it can still ~

Easy_install pyflakes // maybe nedd root

Flake8


This is my recommendation, but it does not affect other people's liking for pylint. In fact, this buddy is a mass integrator and is packaged with the following three tools:

PyFlakes

Pep8

Ned Batchelder's McCabe script

The advantage is not mentioned. The key is to be scalable. here we are very clear: https://pypi.python.org/pypi/flake8/2.0. The installation is as follows:

Easy_install flake8 // maybe nedd root

If you like Git like me, you are also pyhoner, and there are benefits to write the following code into. git/hooks/pre-commit:

#! /Usr/bin/env python

Import sys

From flake8.hooks import git_hook


COMPLEXITY = 12

STRICT = True


The code will not be explained. the official document is clearly written: http://flake8.readthedocs.org/en/latest/vcs.html?git-hook. If your pre-commit script already has rules, it's okay. Call python in shell.

If you like vim


Vim, one of the two major artifacts, naturally requires plug-ins to enjoy the above tools:

Nvie/vim-flake8

Vim-scripts/pylint. vim

If you see the list above, you should know what I'm talking about. that's right. use vundle to install it:

"Flake8 plugin for Vim.

Bundle 'example E/vim-flake8'

"Compiler plugin for python style checking tool.

Bundle 'vim-scripts/pylint. vim'

Autocmd FileType python compiler pylint


If you really don't know vundle, it's time to use her: https://github.com/gmarik/vundle. If you think this is troublesome, use my vimrc directly. here:


Git clone https://github.com/icocoa/icocoa-vimrc.git -- recursive vimrc // icocoa is my another account in GitHub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.