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.

int

Arbitrary-precision integers. Decimal, hex, octal, binary literals. No overflow.

int
float

64-bit IEEE 754 doubles. Rounding pitfalls and decimal.Decimal for exact arithmetic.

float
complex

Real plus imaginary. Rare outside numerical work.

complex
bool

Truthiness rules, short-circuit and / or, idiomatic empty-check.

bool
str

Immutable Unicode. Literals, f-strings, methods, slicing, building, regex.

str
bytes

Immutable byte sequence; the wire-format type. Plus bytearray and memoryview.

bytes
None

The single NoneType value. is None is the idiomatic null check.

None

Composites#

Containers built into the language.

list

Mutable, ordered, indexable sequence.

list
tuple

Immutable, ordered sequence. Heterogeneous record or lightweight value object.

tuple
dict

Insertion-ordered key-value map.

dict
set

Mutable, unordered collection of unique hashable values.

set
frozenset

Immutable, hashable set.

frozenset
range

Lazy integer sequence.

range

For the deeper container catalog and the collections module, see Data Structures.

Conversion#

Cast

Constructors double as casts. Failure modes for each.

Cast
Hints

The optional static-typing layer. mypy / pyright, generics, protocols, TypedDict.

Hints

References#