Python’s built-in functions are always available — no import needed — because
they live in the builtins module that is in scope everywhere. They cover type
conversion, iteration, math, I/O, and introspection. This is a searchable offline
reference with signatures and return types.
How it works
Each entry lists the call signature and the return type so you can see at a glance what a function expects and produces:
- Type constructors (
int,str,list,dict,set) build or convert values and are exposed as callables. - Iterable tools (
map,filter,zip,enumerate,sorted,reversed) transform sequences; several return lazy iterators rather than lists. - Math (
abs,sum,min,max,round,pow,divmod) operate on numbers. - Introspection (
type,isinstance,getattr,dir,vars,hasattr) inspect objects at runtime. - I/O and execution (
print,input,open,repr,eval) interact with the outside world.
Example
enumerate and zip are the idiomatic way to iterate:
for i, (name, score) in enumerate(zip(names, scores), start=1):
print(i, name, score)
map/filter return lazy iterators — wrap in list(...) to materialize.
Frequently confused pairs
Some built-ins look similar but have important behavioral differences. These are the pairs that trip up Python learners most often:
sorted vs list.sort
sorted(iterable) returns a new sorted list from any iterable, leaving the original intact. list.sort() sorts the list in place and returns None. Use sorted when you need the result assigned to a variable, or when you are sorting a tuple, set, or other non-list iterable. Use .sort() when you own the list and want to avoid creating a copy.
scores = [5, 3, 8, 1]
ranked = sorted(scores) # scores unchanged; ranked is a new list
scores.sort() # scores itself is now sorted; returns None
map vs list comprehension
map(func, iterable) applies a single function to every item and returns a lazy iterator. A list comprehension builds the full list at once and can include conditions, multiple variables, and arbitrary expressions. map is concise for a simple function call; a comprehension is usually more readable for anything more complex.
doubles = list(map(lambda x: x * 2, numbers)) # map + lambda
doubles = [x * 2 for x in numbers] # cleaner comprehension
any vs all
any(iterable) returns True if at least one element is truthy; all(iterable) returns True only if every element is truthy. Both short-circuit and work with lazy iterables.
isinstance vs type
type(obj) is int is a strict identity check — it returns False for subclasses. isinstance(obj, int) returns True for instances of int and any subclass of int. Prefer isinstance in most code, especially when working with inheritance hierarchies.
Notes
- Many iterable functions (
map,filter,zip,range,reversed) return lazy iterators in Python 3 — they compute values only as consumed. sortedreturns a new list;list.sort()sorts in place and returnsNone.rounduses banker’s rounding (round half to even), soround(0.5)is0andround(1.5)is2.- This reference covers the common built-ins, not every name or built-in exception. Consult the official docs for version-exact behavior.