Member Login:

Python 3 Style Guide: Naming Convention

Document Reference: TN201311002 - Rev: 4.11 - Last Update: 12-01-2014 18:47 GMT - Downloaded: 17-Jul-2024 22:03 GMT

The goal of this Python 3 naming convention is to reduce the effort needed to read and understand code and variable scope by applying a consistent naming standard.

Good Practice

Avoid Characters I, l Or O

The single characters I (aka capital letter of i), l (aka lowercase of L) or O (aka capital letter of o) should not be used as variable names. These variable names could easily be mistaken as numerals 1 (one) and 0 (zero).

Meaningful Names

To help clearly document what the name is used for, choose meaningful and descriptive names that implies the intent and meaning of the code. Names can contain both letters, numbers and underscores. However, names cannot start with a number. Remember that names are case sensitive.


Use lower_case_with_underscores for naming variables, e.g. variable_name.

MCR Style Configuration Example



MCR Style Configuration Example


Use lower_case_with_underscores for naming functions, e.g. function_name().

MCR Style Configuration Example


Use UpperCamelCase (CapWords) for naming classes, e.g. ClassName. Capitalize all the letters of abbreviations, e.g. HTTPError.

MCR Style Configuration Example

Reserved Keywords

Listed keywords (aka identifiers) below are reserved by Python 3 and must not be used when choosing names:

  • False
  • None
  • True
  • and
  • as
  • assert
  • break
  • class
  • continue
  • def
  • del
  • elif
  • else
  • except
  • finally
  • for
  • from
  • global
  • if
  • import
  • in
  • is
  • lambda
  • nonlocal
  • not
  • or
  • pass
  • raise
  • return
  • try
  • while
  • with
  • yield
Python Code Example

Try code example below to view a list of all Python 3 keywords:

 import keyword

This website uses cookies to give you the best experience on our website, to personalise content and to analyse our website traffic. Some cookies may have been set already. To find out more about our use of cookies you can visit our Privacy Statement. By browsing this website, you agree to our use of cookies.

Hide this message