0
PEP 8: STYLE GUIDE FOR PYTHON CODE

PEP 8

STYLE GUIDE FOR PYTHON CODE

PYTHON

MEDIUM

last hacked on Sep 24, 2017

PEP stands for _Python Enhancement Proposals_. PEP 8, specifically, refers to writing readable code. According to Guido van Rossum, "Code is read more often than it is written."
This project goes over indentation, standard code layout, and naming conventions, as recommended by PEP 8. # Indentation Python uses different ways of encoding indentation: * Space characters * Tab characters PEP 8 recommends that Python developers **do not** mix the use of space and tab characters within the Python script. If Python developers should use Space characters, they should use four space characters to indicate one level of indentation. If Python developers should use Tab characters instead, Tab character length should be equivalent to four Space characters. And one Tab character should be used to indicate one level of indentation. # Standard Code Layout """Demonstrate PEP 8 layout This module does nothing useful, aside from demonstrating most of the layout rules of PEP 8. """ import sys import re from pickle import loads, dumps class Elephant: """Tracks elephants and their optional associated dormice. """ def __init__(self, dormouse = None): """Create an Elephant, and optionally tie it to a DorMouse. If specified, the dormouse parameter should be a DorMouse instance which should be associated with this Elephant. """ self.dormouse = dormouse if dormouse: dormouse.set_elephant(self) ... Import statements should be placed at the top of the file, with library imports first, followed by third party imports, then imports from other modules within the same project. # Naming Conventions Missing. # Finish this project [Mastering Python Tutorial: PEP 8 and Writing Readable Code | packtpub.com](https://www.youtube.com/watch?v=zs6BzkgHvMA&t=240s)

COMMENTS


back to all projects