liveBook · Manning

Built-in namespace

The built-in namespace is Python’s namespace containing predefined names available during ordinary name resolution without explicit definition or import.

How 3 Manning books explain it

The Quick Python Book, Fourth Edition

The built-in namespace is the namespace containing Python's predefined names, including built-in functions and exceptions.

How it is used
Supplies predefined functions and exceptions during name lookup after local and global namespaces are checked.
How deep it goes
Explains lookup order, contents, inspection, and shadowing with a worked failure and recovery, without detailing interpreter internals.
Examples
Uses `dir(__builtins__)` and a reassigned `list` that raises TypeError until `del list` removes the binding.
What you can do after
Diagnose/debug with it when a built-in name is hidden, using `dir()` to inspect names and `del` to remove an accidental binding.

Read how The Quick Python Book, Fourth Edition explains built-in namespace →

Python Workout: 50 ten-minute exercises

The built-ins namespace is Python's namespace containing names available as a final fallback during ordinary name resolution, including built-in functions and types.

How it is used
Resolves ordinary names after local, enclosing, and global namespaces have been searched.
How deep it goes
Explains lookup order and shadowing with a failure example, but stops short of namespace implementation internals.
Examples
Uses int, range, sum, a shadowing error, pylint, lists, dicts, and os imports.
What you can do after
Diagnose/debug with it by recognizing built-in shadowing and distinguishing built-ins from modules requiring import.

Read how Python Workout: 50 ten-minute exercises explains built-in namespace →

Python Workout, Second Edition

builtins is Python's namespace and module containing names automatically available to Python code.

How it is used
Resolves unqualified names after globals in LEGB lookup, making common types and functions available without global definitions.
How deep it goes
Explains lookup order and shadowing consequences, including the resulting TypeError from calling a shadowed name.
Examples
Uses int('s'), a shadowed sum variable, sum([...]), and pylint or ruff diagnostics.
What you can do after
Diagnose name-resolution errors by checking globals before built-ins and identifying collisions such as sum.

Read how Python Workout, Second Edition explains built-in namespace →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.