Developpez.com

Python

Choisissez la catégorie, puis la rubrique :

3.2 Boolean Operations -- and, or, not


3.2 Boolean Operations -- and, or, not

These are the Boolean operations, ordered by ascending priority:

Operation Result Notes
x or y if x is false, then y, else x (1)
x and y if x is false, then x, else y (1)
not x if x is false, then True, else False (2)

Notes:

(1)
These only evaluate their second argument if needed for their outcome.

(2)
"not" has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error.

See About this document... for information on suggesting changes.
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web