Built-in Functions

All built-in names (functions, exceptions, and so on) exist in the implied outer built-in scope, which corresponds to the _ _builtin_ _ module. Because this scope is always searched last on name lookups, these functions are always available in programs without imports. However, their names are not reserved words and may be hidden by assignments to the same name in global or local scopes.

abs(N)

Returns the absolute value of a number N.

apply(func, args [, keys])

Calls any callable object func (a function, method, class, etc.), passing the positional arguments in tuple args, and the keyword arguments in dictionary keys. Returns func call result.

buffer(object [, offset [, size]])

Returns a new buffer object for a conforming object (see the Python Library Reference).

callable(object)

Returns 1 if object is callable; else, returns 0.

chr(Int)

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

cmp(X, Y)

Returns a negative integer, zero, or a 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 a Python string containing Python program code. filename is a string used in error messages (and is usually the name of the file from which the code was read, or <string> if typed interactively). kind can be exec if string contains statements; eval if string is an expression; ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.