Boolean operations have the lowest priority of all Python operations:
In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are interpreted
(Note that neither and nor or restrict the value
and type they return to
Lambda forms (lambda expressions) have the same syntactic position as
expressions. They are a shorthand to create anonymous functions; the
See section 7.5 for the syntax of parameter lists. Note that functions created with lambda forms cannot contain statements.
Programmer's note: Prior to Python 2.1, a lambda form defined inside a function has no access to names defined in the function's namespace. This is because Python had only two scopes: local and global. A common work-around was to use default argument values to pass selected variables into the lambda's namespace, e.g.:
As of Python 2.1, nested scopes were introduced, and this work-around has not been necessary. Python 2.1 supports nested scopes in modules which include the statement "from __future__ import nested_scopes", and more recent versions of Python enable nested scopes by default. This version works starting with Python 2.1:
See About this document... for information on suggesting changes.