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
True
only if all elements of theiterable
are true.any(iterable)
Returns
True
only if any element of theiterable
is 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\U
escapes. 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
N
is not a Pythonint
object, it must define an__index__()
method that returns an integer. See alsoint(x, 2)
to convert from binary,0bNNN
binary literals, and theb
type code instr.format()
.bool([x])
Converts a value to a Boolean, using the standard truth testing procedure. If
x
is false or omitted, this returnsFalse
; otherwise, it returnsTrue
.bool
is also a class, which is a subclass ofint
. The classbool
cannot be subclassed further. Its only instances areFalse
andTrue
.bytearray([arg [, ...
Get Python Pocket Reference, 4th 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.