1. Technology

Python Built-In Modules: Boolean Operations

By

txjs_2013.113-001
TR4NSLATOR/Flikr/CC BY 2.0

These are the Boolean operations, ordered by ascending priority:

  • x or y: if x is false, then y, else x. The second argument is only evaluated if needed.
  • x and y: if x is false, then x, else y. The second argument is only evaluated if needed.
  • not x: if x is false, then True, else False. not has a lower priority than non-Boolean operators, so "not a == b" is interpreted as "not (a == b)". "a == not b" is regarded as a syntax error.
  1. About.com
  2. Technology
  3. Python
  4. Python Library
  5. Python Modules - Boolean Operations - Boolean Operators

©2014 About.com. All rights reserved.