Writing code actually needs to be standardized, especially in the team, or Google will not release a variety of coding specifications, familiar with the Google C + + style guide, Google Python style guide, and so on.
Are these specifications useful? Useful is useless, unless you have a good mind, while coding, while the standard use of purple; otherwise we need a tool to do it. Fortunately, Python has more than one tool to do this for us. Say Hugh verses, cut to the chase.
Pylint
Used, perverted to purple, do not know who is so bored, the rules of the death, we pythoner can be happy? What do they not see Rubyer,matz advocating? Happy Coding have wood? So I used to still, because I do not need so perverted, no Love ~ if you want to install, it is very simple:
Easy_install Pylint//maybe Nedd root
Pep8
As the name implies, it comes from the Python community's famous PEP 8. Basically write the code that's right, but it's not perfect; Install the following:
Easy_install Pep8//maybe Nedd root
Pyflakes
Python Program Passive Detection tool, also really enough passive, according to the author said relatively fast, not strong enough, but also can ~
Easy_install Pyflakes//maybe Nedd root
Flake8
The protagonist has appeared, this is my recommendation, but does not affect other people like pylint. In fact, this buddy is the master, is the following three tools packaging:
Pyflakes
Pep8
Ned Batchelder ' s McCabe script
The advantage is not to say, the key is extensible, here is very clear: https://pypi.python.org/pypi/flake8/2.0. Install the following:
Easy_install Flake8//maybe Nedd root
If you like me the same as Git, then you are Pyhoner, then there are benefits, write the following code. Git/hooks/pre-commit:
#!/usr/bin/env python
Import Sys
From Flake8.hooks import Git_hook
complexity = 12
STRICT = True
The code does not explain it, and the official document is written clearly: Http://flake8.readthedocs.org/en/latest/vcs.html#git-hook. If your pre-commit script already has rules, it's okay to call Python in the shell.
If you also like Vim
As one of the two major artifacts of vim, naturally need to have plug-ins to enjoy the above tools:
Nvie/vim-flake8
Vim-scripts/pylint.vim
See the list above, you should know what I'm talking about, yes, install with Vundle:
"Flake8 plugin for Vim.
Bundle ' Nvie/vim-flake8 '
The 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 really time to use her: Https://github.com/gmarik/vundle. If you think it's all in trouble, just use my vimrc, here:
git clone https://github.com/icocoa/icocoa-vimrc.git--recursive VIMRC//Icocoa is my another account in GitHub