Flip Comparison
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: flip-comparison
Section titled “Sourcery refactoring id: flip-comparison”Description:
Section titled “Description:”Moves variables from the right side to the left side of comparisons
Before:
Section titled “Before:”if 1 == x: do_x()After:
Section titled “After:”if x == 1: do_x()Explanation:
Section titled “Explanation:”It is a coding convention that when doing comparisons to a numeric constant, the number should be on the right and the variable on the left. Having things be consistent in this way makes the code easier to read.