Here’s the summary of PEP8, a badly formatted guide to Python style which also imparts random programming advice.
Capitalization
_private, keyword_, __mangled_private, module, _extension, ClassName, _PrivateClassName, ExceptionError, function_name, global_variables, instance_methods, _private_instance_methods, instance_variables, _private_instance_variables,
* Follow the existing module convention over these rules
* _private Leading underscore to make a weak internal or private indication.
* keyword_ Trailing underscore to avoid conflict with keyword.
* __mangled_private Double leading underscore invokes name mangling privacy
* module Package names are all lower case, short, and may use underscores.
* _extension C and C++ extension modules have a leading underscore.
* ClassName Class names use CapWords.
* _PrivateClassName Class names can have an underscore to indicate internal use.
* ExceptionError Exceptions are CapWords classes and end with Error if they are errors.
* function_name Function names are lowercase with underscore seperators.
* global_variables Globals look like functions with lowercase and underscores.
* instance_methods Instance methods also look like function names.
* _private_instance_methods Private instance methods may use an underscore.
* instance_variables Everything looks like a function name
* _private_instance_variables Everything private looks like a private function name
Style Advice
* Indent 4 spaces per line.
* Limit lines to 79 characters.
* Separate top level methods and classes with two blank lines.
* Separate methods within a class with one line.
* Imports are one per line.
* Avoid spaces immediately inside parenthesis, brackets or braces.
* Avoid spaces immediately before a comma, semicolon, or colon.
* Comments should be complete sentences in English.
* Write good docstrings.
* Version bookkeeping goes after the module’s docstring.
* self is the first argument to all instance methods.
* cls is the first argument to all class methods.
Sorry, not an Idea For Free, but I got sick of trying to read through Pep-8 again to check a style question.
0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment