Python Coding Style

PEP8 has emerged as the style guide that most projects. it promotes a very readable and eye-pleasing coding style.

  1. Use 4-space indentation, and no tabs.
  2. Wrap lines so that they don’t exceed 79 characters.
  3. Use blank lines to separate functions and classes, and larger blocks of code inside functions.
  4. When possible, put comments on a line of their own.
  5. Use docstrings.
  6. Use spaces around operators and after commas, but not directly inside bracketing constructs: a = f(1, 2) + g(3, 4).
  7. Name your classes and functions consistently. Use CamelCase for classes and lower_case_with_underscores for functions and methods. Always use self as the name for the first method argument
  8. Don’t use fancy encodings if your code is meant to be used in international environments. Plain ASCII works best in any case

http://docs.python.org/tutorial/controlflow.html

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License