Built-in Functions
All built-in names (functions, exceptions, and so on) exist in the
implied outer built-in scope, which corresponds to the builtins module (named __builtin__ in Python 2). 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 might be hidden by assignments to the same name in
global or local scopes.
abs(N)Returns the absolute value of a number
N.all(iterable)Returns
Trueonly if all elements of theiterableare true.any(iterable)Returns
Trueonly if any element of theiterableis true.ascii(object)Like
repr(), returns a string containing a printable representation of an object, but escapes the non-ASCII characters in therepr()result string using\x,\u, or\Uescapes. This result is similar to that returned byrepr()in Python 2.X.bin(N)Convert an integer number to a binary (base 2) digits string. The result is a valid Python expression. If argument
Nis not a Pythonintobject, it must define an__index__()method that returns an integer. See alsoint(x, 2)to convert from binary,0bNNNbinary literals, and thebtype code instr.format().bool([x])Converts a value to a Boolean, using the standard truth testing procedure. If
xis false or omitted, this returnsFalse; otherwise, it returnsTrue.boolis also a class, which is a subclass ofint. The classboolcannot be subclassed further. Its only instances areFalseandTrue.bytearray([arg [, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access