Chain Compares
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: chain-compares
Section titled “Sourcery refactoring id: chain-compares”Description
Section titled “Description”Combine two compares on same value into a chained compare
Before
Section titled “Before”if 1 < b and b < 3: print("b is between 1 and 3")if 1 < b < 3: print("b is between 1 and 3")Explanation
Section titled “Explanation”Two compare operations on the same value can be chained together. This is described in detail in the Python comparison docs.
Chaining compares is how they are written in mathematics and makes them easier to read.