Everything is an object
corebeginnerIn Python, a number, a string, a function, a class, and a module are all objects — each has a type, an identity, and can carry attributes. There is no separate category of "primitive" value that behaves differently.
Think of it as
A warehouse where every single item, no matter how small, sits on its own labelled shelf with a tag saying what kind of thing it is. There is no pile of loose, tag-free items on the floor — even the number 5 has a shelf, a type, and an address.
What we're doing: Confirm that a number, a function, and a class itself all report a type and count as objects.
- 1
- add is a function — still an object, with its own type.
- 4
- values mixes a number, a string, a built-in, a class, and a user-defined function.
- 5
- isinstance(v, object) is True for every one of them — object sits at the root of every type.
int True
str True
builtin_function_or_method True
type True
function TrueWhy this works: Python has no separate notion of a raw, un-typed value the way some languages treat integers or booleans as special. Every value — including int and add itself — is built by some class, and type() always answers with that class. That uniformity is why a function can be stored in a list, passed to another function, or given attributes: it is not a special case, just another object.
Assuming numbers are a special, non-object primitive
Wrong
Better
What you see: The wrong version prints <built-in method bit_length of int object at 0x...> — a method object, not the answer — because x.bit_length is only a lookup, not a call.
Why: x is an int object, and int defines methods like any other class — bit_length() is one of them. Forgetting the () is the same mistake as forgetting it on any other object's method; numbers are not exempt from being objects with real, callable attributes.
- 5, "x", a function, a class — every one of these is an object
- type(x) — reports which class built it — always answers something
- isinstance(x, object) — always True — object is the root of every type
type() applied across Python's usual categories
Together
Remember: type(x) answers for any value — a number, a function, or a class. isinstance(x, object) is always True. There is no non-object value in Python.
See also: names vs objects and references · object identity · function objects

