Skip to content
Piyush Parkash edited this page Jun 9, 2014 · 5 revisions

###How to write code?

PEP8 coding standards for python:

  1. 4 spaces Indentation per level.
  2. No mix of tabs or spaces, convert tabs to spaces.
  3. Maximum length of 79 characters.
  4. For docstrings or comments, line length of 72 characters.
  5. 2 blank lines between classes and top level functions.
  6. Single blank line between functions inside a class.
  7. Imports on separate lines.
  8. Blank line between each group of imports.
  9. Whitespace between operands.
  10. No whitespace in parameter values.
  11. Each line of a block comment starts with a # and a single space (unless it is indented text inside the comment). Paragraphs inside a block comment are separated by a line containing a single #.
  12. Never use the characters 'l', 'O', or 'I' as single character variable names.
  13. Package and module names: all-lowercase names, with words separated by underscores.
  14. Class names: CapWords convention.
  15. Use one leading underscore only for non-public methods and instance variables.
  16. Constants written in all capital letters with underscores separating words.
Clone this wiki locally