Built-in Functions

All built-in names (functions and exceptions) exist in the implied outer built-in scope, which corresponds to the __builtin__ module. They are always available in programs without imports (but are not reserved words).


Return the absolute value of a number N.

apply(func, args [, keys])

Call object func (a function, method, or class), passing the positional arguments in tuple args, and keyword arguments in dictionary keys. Returns func result.


Returns 1 if object is callable, else returns 0.


Returns a one-character string whose ASCII code is integer I.

cmp(X, Y)

Returns a negative, zero, or positive integer to designate (X < Y), (X == Y), or (X > Y), respectively.

coerce(X, Y)

Returns a tuple containing the two numeric arguments X and Y converted to a common type.

compile(string, filename, kind)

Compiles string into a code object. string is Python string containing Python program code. filename is a string used in error messages (and is usually the file from which the code was read, or ‘<string>’ if typed interactively). kind can be ‘exec’ if string is statements, ‘eval’ if string is an expression, or ‘single’ which prints the output of expression statements that evaluate to something other than None. The resulting code object can be executed with exec statements or eval calls.

complex(real [, imag])

Builds a complex number object (can also be done using J or j suffix: real+imagJ). imag defaults to 0.

delattr(object, name)

Deletes the attribute named ...

Get Python Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.