Python coding standards

Post on 18-Feb-2017

403 views 2 download

transcript

Python Coding Standards

ssharad@outlook.com

Agenda

Who’s This Guy?

Another One...

Last One.

Terminology - PEP- Python Enhancement Proposal

- PEP stands for Python Enhancement Proposal. A PEP is a design

document providing information to the Python community, or describing

a new feature for Python or its processes or environment. The PEP

should provide a concise technical specification of the feature and a rationale for the feature.

- PEP 0001: https://www.python.org/dev/peps/pep-0001/

The Philosophy - Core MantrasCode is read much more often than it is written.

Python Style Guide- PEP-0008

- Coding conventions- https://www.python.org/dev/peps/pep-0008/

- PEP-0257- Docstring conventions- https://www.python.org/dev/peps/pep-0257/

PEP8- http://pep8.readthedocs.org/en/latest/intro.html- 72 error codes (as of Nov 27, 2015)

- Samples:

PEP257- http://pep257.readthedocs.org/en/latest/- 24 error codes (as of Nov 27, 2015)- Samples:

Quick Re-Cap

The How Part Of It - Some Handy Tools- pep8- pep257- pylint- autopep8

More On Setting Up Tools● Pylint

http://www.pylint.org/ http://docs.pylint.org/index.html

● pep8, pep257 sudo pip install pep8 sudo pip install pep257 pep8 --statistics <repository path> pep257 <repository path>

● IDEs○ PyCharm

■ PyCharm: https://www.jetbrains.com/pycharm/

■ Integrate Pylint in PyCharm: http://softwaretester.info/integrate-pylint-in-pycharm/

■ Running Pylint in PyCharm: http://blog.saturnlaboratories.co.za/archive/2012/09/10/running-pylint-pycharm

■ Write Clean, Professional, Maintainable, Quality Code in Python: http://blog.jetbrains.com/pycharm/2014/06/write-clean-professional-maintainable-quality-code-in-python/

More On Setting Up Tools, Contd.● IDEs

○ Sublime Text■ Sublime Text: http://www.sublimetext.com/■ SublimeLinter: http://www.sublimelinter.com/en/latest/■ SublimeLinter plugin for python, using Pylint: https://github.

com/SublimeLinter/SublimeLinter-pylint■ Pylint in Sublime Text: http://stackoverflow.com/questions/16794613/pylint-

in-sublime-text-2■ Install Anaconda: http://damnwidget.github.io/anaconda/■ Change Anaconda-settings(for 120 lines) -■ Package Settings -> Anaconda -> User Settings – here add following

entries -:■ "pep8": true■ "pep8_max_line_length": 120

Make Your Manager(s) Happy - Show Them Some Graphs

Some More...

And Done!!!