O'Reilly logo

Expert Python Programming - Second Edition by Tarek Ziadé, Michał Jaworski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Naming styles

The different naming styles used in Python are:

  • CamelCase
  • mixedCase
  • UPPERCASE, and UPPER_CASE_WITH_UNDERSCORES
  • lowercase and lower_case_with_underscores
  • _leading and trailing_ underscores, and sometimes __doubled__ underscores

Lowercase and uppercase elements are often a single word, and sometimes a few words concatenated. With underscores, they are usually abbreviated phrases. Using a single word is better. The leading and trailing underscores are used to mark the privacy and special elements.

These styles are applied to:

  • Variables
  • Functions and methods
  • Properties
  • Classes
  • Modules
  • Packages

Variables

There are two kinds of variables in Python:

  • Constants
  • Public and private variables

Constants

For constant global variables, an uppercase with an underscore ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required