Types#
Python is dynamically typed. Every value carries its own type,
and the operator binds names to values, not to types. Type hints
are optional and not enforced at runtime; tools like mypy and
pyright check them statically.
For binding rules see Variables. For the operators that act on each type, see Operators.
Primitives#
The scalar types the operator works with directly.
Arbitrary-precision integers. Decimal, hex, octal, binary literals. No overflow.
64-bit IEEE 754 doubles. Rounding pitfalls and
decimal.Decimal for exact arithmetic.
Real plus imaginary. Rare outside numerical work.
Truthiness rules, short-circuit and / or, idiomatic
empty-check.
Immutable Unicode. Literals, f-strings, methods, slicing, building, regex.
Immutable byte sequence; the wire-format type. Plus
bytearray and memoryview.
The single NoneType value. is None is the idiomatic
null check.
Composites#
Containers built into the language.
Mutable, ordered, indexable sequence.
Immutable, ordered sequence. Heterogeneous record or lightweight value object.
Insertion-ordered key-value map.
Mutable, unordered collection of unique hashable values.
Immutable, hashable set.
Lazy integer sequence.
For the deeper container catalog and the collections module,
see Data Structures.
Conversion#
Constructors double as casts. Failure modes for each.
The optional static-typing layer. mypy / pyright,
generics, protocols, TypedDict.
References#
Variables for binding and scope.
Data Structures for the deeper container catalog.
OOP for protocols, dataclasses, and structural typing.
Operators for the operators that act on each type.
Regex for the regex DSL deep dive.
Built-in Types in the standard library.