De Morgan's Laws
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: de-morgan
Section titled “Sourcery refactoring id: de-morgan”Description:
Section titled “Description:”Simplifies conditional logic using De Morgan’s laws
Before:
Section titled “Before:”if not not p: a = 1if not a is b: a = 1if not (p == 1 and q == 2): a = 1After:
Section titled “After:”if p: a = 1if a is not b: a = 1if p != 1 or q != 2: a = 1Explanation:
Section titled “Explanation:”When reading logical statements it is important for them to be as simple as possible. This proposal applies De Morgan’s laws to simplify code by removing double negatives or pushing negations deeper into statements.