Python Naming Conventions

The naming styles

  • b (single lowercase letter)
  • B (single uppercase letter)
  • lowercase
  • lower_case_with_underscores
  • CapitalizedWords (or CapWords, or CamelCase – so named because of the bumpy look of its letters [4]). This is also sometimes known as StudlyCaps.Note: When using acronyms in CapWords, capitalize all the letters of the acronym. Thus HTTPServerError is better than HttpServerError.
  • mixedCase (differs from CapitalizedWords by initial lowercase character!)
  • Capitalized_Words_With_Underscores (ugly!)

Class Names

Class names should normally use the CapWords convention.

Function Names

Function names should be lowercase, with words separated by underscores as necessary to improve readability. (lower_case_with_underscores)

Variable Names

Variable names follow the same convention as function names.