AI Skill Report Card

Explaining Python Builtin Constants

B68·Aug 12, 2026·Source: Web
Markdown
--- name: explaining-python-builtin-constants description: Explains Python's built-in constants (True, False, None, NotImplemented, Ellipsis, __debug__) and site-module-added constants (quit, exit, copyright, credits, license). Use when clarifying constant behavior, differences between them, or interactive-shell-only availability. ---
11 / 15
Python
>>> None is None True >>> NotImplemented # used by rich comparison/binary ops, not general code NotImplemented >>> ... is Ellipsis # `...` literal is Ellipsis True >>> __debug__ # False when run with -O True >>> exit() # only in interactive interpreter / site module enabled
Recommendation
Fix the Quick Start example: `__debug__` output shown as True is fine but the comment 'False when run with -O' right above a normal run is confusing—clarify context or show both cases
13 / 15
  1. Identify which category the constant belongs to:

    • Core language constants (always available, part of builtins): True, False, None, NotImplemented, Ellipsis/..., __debug__
    • Site-module constants (added by site.py, interactive convenience only): quit, exit, copyright, credits, license
  2. Explain semantics accurately:

    • True/False: instances of bool, subclass of int (True == 1, False == 0)
    • None: sole instance of NoneType, represents absence of a value
    • NotImplemented: return value from rich comparison/arithmetic special methods signaling "try the other operand's method"; not the same as raising NotImplementedError
    • Ellipsis: singleton, written as ..., used in slicing, type stubs, stub bodies
    • __debug__: True unless Python started with -O/-OO; guards assert statements
    • quit/exit: callables (instances of _sitebuiltins.Quitter) that raise SystemExit; only guaranteed in interactive mode — absent if site module is disabled (-S flag) or in some embedded contexts
    • copyright/credits/license: callables that print interpreter info when called (e.g. license()), added by site module
  3. Flag common confusions:

    • NotImplemented vs NotImplementedError (data value vs exception class)
    • exit()/quit() are not meant for use in production scripts — use sys.exit() instead
    • These site-module constants may not exist if site.py wasn't imported (python -S)
Recommendation
This skill is reference/explanatory knowledge Claude likely already has fluently; consider whether it needs to exist as a skill vs. being general knowledge, or sharpen it toward a specific non-obvious use case (e.g., debugging site-module absence issues)
15 / 20

Example 1: Input: "What's the difference between NotImplemented and NotImplementedError?" Output: NotImplemented is a singleton value returned from methods like __eq__, __lt__, __add__ to tell Python "I don't know how to handle this operand type, try the reflected method or fall back." Python then either calls the other object's method or raises TypeError itself. NotImplementedError is an exception class, typically raised in abstract base methods to signal a subclass must override them. Returning NotImplementedError() instead of NotImplemented from __eq__ is a common bug — it won't trigger Python's fallback protocol.

Example 2: Input: "Why does exit() work in my REPL but fail in my script run with python -S script.py?" Output: exit and quit aren't language builtins — they're injected into the builtins namespace by the site module specifically for interactive convenience. The -S flag skips site initialization, so those names are never defined. For scripts, always use sys.exit([code]) from the sys module, which is guaranteed available.

Example 3: Input: "Does assert cost anything in production?" Output: assert expr, msg compiles to a check guarded by __debug__. Running Python with -O sets __debug__ to False and the compiler strips assert statements entirely — no runtime cost. Don't rely on assert for input validation that must run in production; use explicit if/raise instead.

Recommendation
Add a case where the constant behavior causes a real bug (e.g., a full before/after code diff for the NotImplemented bug) to strengthen the examples section
  • Point users to sys.exit() over exit()/quit() in any non-interactive code
  • Clarify that True/False/None are keywords (cannot be reassigned) as of Python 3, unlike NotImplemented/Ellipsis which are ordinary names bound to singletons
  • Mention ... as a valid no-op placeholder in function bodies and type stubs, equivalent to pass but semantically "not implemented yet"
  • When discussing __debug__, tie it to the -O/-OO flags and PYTHONOPTIMIZE env var
  • Don't claim quit/exit/copyright/credits/license are guaranteed builtins — they depend on the site module being loaded
  • Don't confuse NotImplemented (value) with raising NotImplementedError (exception)
  • Don't say assert is "always safe to use for validation" — it disappears under -O
  • Don't treat Ellipsis as Python-2-only trivia — it's actively used in NumPy slicing and type stub (.pyi) syntax
0
Grade BAI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
11/15
Workflow
13/15
Examples
15/20
Completeness
15/20
Format
13/15
Conciseness
13/15