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


Syntactically, expressions consist of one or more nested primaries elements. When multiple primaries are used, they’re combined using operators.

For a full description of Python’s expression syntax, see expressions.

Expression Lists

In many places, you can use expression lists instead of simple expressions. An expression list is simply a comma-separated list of expressions, which Python treats as a sequence.

expression [, expression]… [,]

An expression list containing at least one comma yields a tuple. The length of the tuple is the number of expressions in the list. The expressions are evaluated from left to right.

The trailing comma is required only to create a single tuple (a.k.a. a singleton); it is optional in all other cases. A single expression without a trailing comma doesn’t create a tuple, but rather yields the value of that expression. (To create an empty tuple, use an empty pair of parentheses: ().)