TL;DR
Python's pre-declared constants, such as True and False, are unique as they are treated as distinct lexical tokens rather than identifiers. This design choice leads to some unexpected behaviors in the language.
✦ Why It Matters
Review your use of Python constants to ensure clarity and avoid unexpected behaviors in your code.
Key Takeaways
How It Works
Python's constants like True, False, and None are treated as lexical tokens, meaning they are recognized by the lexer before name resolution occurs. This unique treatment leads to specific syntax rules, such as raising SyntaxError for invalid expressions involving these constants.
The __debug__ constant, while not a keyword, is special-cased to prevent assignment, making it behave like a constant despite being an identifier.
Related