• Use 4-space inden­ta­tion, no tabs

 

  • Wrap lines so that they don’t exceed 79 characters

 

  • Use blank lines to sep­a­rate func­tions and classes, and larger blocks of code inside functions

 

  • When pos­si­ble, put com­ments on a line of their own

 

  • Use doc­strings

 

  • Use spaces around oper­a­tors and after commas

 

  • Name your classes and func­tions con­sis­tently; the con­ven­tion is to use Camel­Case for classes and lower_case_with_underscores for func­tions and methods

 

  • Always use self as the name for the first method argument

 

  • Don’t use fancy encod­ings if your code is meant to be used in inter­na­tional environments

    Nam­ing conventions:

    Vari­ables / func­tions — use_lower_case_separated_by_underscore

    Class names — UseCamelCase

    Error classes end in Error, i.e. MyError

Share

Leave a Reply