Non Equal 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: non-equal-comparison
Section titled “Sourcery refactoring id: non-equal-comparison”Description
Section titled “Description”Simplify comparison of non equal values
Before
Section titled “Before”def compare(a: int, b: int): if a < b: return True elif a > b: return Falsedef compare(a: int, b: int): if a != b: return a < bExplanation
Section titled “Explanation”If we are comparing two numbers and returning only if they are non equal we can simplifiy the form of this expression.
Removing an if statement and merging two comparisons makes the code shorter and easier to read.