python coding standards

19
Python Coding Standards [email protected]

Upload: sharad-singla

Post on 18-Feb-2017

413 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Python coding standards

Python Coding Standards

[email protected]

Page 2: Python coding standards

Agenda

Page 3: Python coding standards

Who’s This Guy?

Page 4: Python coding standards

Another One...

Page 5: Python coding standards

Last One.

Page 6: Python coding standards

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/

Page 7: Python coding standards

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

Page 8: Python coding standards

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/

Page 9: Python coding standards

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

- Samples:

Page 10: Python coding standards

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

Page 11: Python coding standards

Quick Re-Cap

Page 12: Python coding standards

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

Page 13: Python coding standards

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/

Page 14: Python coding standards

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

Page 15: Python coding standards

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

Page 16: Python coding standards

Some More...

Page 17: Python coding standards

And Done!!!

Page 18: Python coding standards