We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.


COMMENT: This page is being refactored

This chapter explains the meaning of the elements of expressions in Python.


Atoms are the most basic elements of expressions. The simplest atoms are identifiers or literals. Subexpressions enclosed in reverse quotes or in parentheses, brackets or braces are also categorized syntactically as atoms.

An atom can be one of:

See syntax-atom.

Arithmetic conversions

When a description of an arithmetic operator below uses a phrase like the numeric arguments are converted to a common type, the arguments are coerced using Python’s standard coercion-rules. If both arguments are standard numeric types, the following coercions are applied:

  • If either argument is a complex number, the other is converted to complex;
  • otherwise, if either argument is a floating point number, the other is converted to floating point;
  • otherwise, if either argument is a long integer, the other is converted to long integer;
  • otherwise, both must be plain integers and no conversion is necessary.

Some additional rules apply for certain operators (e.g., a string left argument to the ‘%’ operator). Extensions can define their own coercions.