PyDocs

Python Runtime Services

builtins

Built-in functions, types, exceptions, and other objects.

This module provides direct access to all 'built-in'
identifiers of Python; for example, builtins.len is
the full name for the built-in function len().

This module is not normally accessed explicitly by most
applications, but can be useful in modules that provide
objects with the same name as a built-in value, but in
which the built-in of that name is also needed.
Symbols in builtins

_

__debug__
This constant is true if Python was not started with an -O option.
__import__
Import a module.

a

abs
Return the absolute value of the argument.
agen.__anext__
Returns an awaitable which when run starts to execute the asynchronous generator function or resumes it at the yield expression where the function is currently suspended.
agen.aclose
Returns an awaitable that when run will throw a GeneratorExit into the underlying asynchronous generator function at the point where it is currently suspended (equivalent to calling athrow(GeneratorE…
agen.asend
Returns an awaitable which, when run, “sends” a value into the underlying asynchronous generator function: the value argument becomes the result of the current yield expression.
agen.athrow
Returns an awaitable that, when run, raises an exception at the point where the underlying asynchronous generator function is currently suspended.
aiter
Return an AsyncIterator for an AsyncIterable object.
all
Return True if bool(x) is True for all values x in the iterable.
anext
Return the next item from the async iterator.
any
Return True if bool(x) is True for any x in the iterable.
ArithmeticError
Base class for arithmetic errors.
ascii
Return an ASCII-only representation of an object.
AssertionError
Assertion failed.
AttributeError
Attribute not found.

b

BaseException
Common base class for all exceptions
BaseExceptionGroup
A combination of multiple unrelated exceptions.
bin
Return the binary representation of an integer.
BlockingIOError
I/O operation would block.
bool
Returns True when the argument is true, False otherwise.
breakpoint
Call sys.breakpointhook(*args, **kws).
BrokenPipeError
Broken pipe.
BufferError
Buffer error.
bytearray
Construct a mutable bytearray object from: - an iterable yielding integers in range(256) - a text string encoded using the specified encoding - a bytes or a buffer object - any object implementing th…
bytes
Construct an immutable array of bytes from: - an iterable yielding integers in range(256) - a text string encoded using the specified encoding - any object implementing the buffer API.
BytesWarning
Base class for warnings about bytes and buffer related problems, mostly related to conversion from str or comparing to str.

c

callable
Return whether the object is callable (i.e., some kind of function).
ChildProcessError
Child process error.
chr
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.
classmethod
Convert a function to be a class method.
codeobject.co_argcount
The total number of positional parameters (including positional-only parameters and parameters with default values) that the function has
codeobject.co_cellvars
A tuple containing the names of local variables that are referenced from at least one nested scope inside the function
codeobject.co_code
A string representing the sequence of bytecode instructions in the function
codeobject.co_consts
A tuple containing the literals used by the bytecode in the function
codeobject.co_filename
The name of the file from which the code was compiled
codeobject.co_firstlineno
The line number of the first line of the function
codeobject.co_flags
An integer encoding a number of flags for the interpreter.
codeobject.co_freevars
A tuple containing the names of free (closure) variables that a nested scope references in an outer scope.
codeobject.co_kwonlyargcount
The number of keyword-only parameters (including arguments with default values) that the function has
codeobject.co_lines
Returns an iterator that yields information about successive ranges of bytecodes.
codeobject.co_linetable
A bytes object containing encoded source location information.
codeobject.co_name
The function name
codeobject.co_names
A tuple containing the names used by the bytecode in the function
codeobject.co_nlocals
The number of local variables used by the function (including parameters)
codeobject.co_positions
Returns an iterable over the source code positions of each bytecode instruction in the code object.
codeobject.co_posonlyargcount
The number of positional-only parameters (including arguments with default values) that the function has
codeobject.co_qualname
The fully qualified function name Added in version 3.11.
codeobject.co_stacksize
The required stack size of the code object
codeobject.co_varnames
A tuple containing the names of the local variables in the function (starting with the parameter names)
codeobject.replace
Return a copy of the code object with new values for the specified fields.
compile
Compile source into a code object that can be executed by exec() or eval().
complex
Create a complex number from a string or numbers.
ConnectionAbortedError
Connection aborted.
ConnectionError
Connection error.
ConnectionRefusedError
Connection refused.
ConnectionResetError
Connection reset.
container.__iter__
Return an iterator object.
contextmanager.__enter__
Enter the runtime context and return either this object or another object related to the runtime context.
contextmanager.__exit__
Exit the runtime context and return a Boolean flag indicating if any exception that occurred should be suppressed.
copyright
Objects that when printed or called, print the text of copyright or credits, respectively.
coroutine.close
Causes the coroutine to clean itself up and exit.
coroutine.send
Starts or resumes execution of the coroutine.
coroutine.throw
Raises the specified exception in the coroutine.
credits
Objects that when printed or called, print the text of copyright or credits, respectively.

d

definition.__doc__
The documentation string of a class or function, or None if undefined.
definition.__module__
The name of the module in which a class or function was defined.
definition.__name__
The name of the class, function, method, descriptor, or generator instance.
definition.__qualname__
The qualified name of the class, function, method, descriptor, or generator instance.
definition.__type_params__
The type parameters of generic classes, functions, and type aliases.
delattr
Deletes the named attribute from the given object.
DeprecationWarning
Base class for warnings about deprecated features.
dict
(key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword …
dir
If called without an argument, return the names in the current scope.
divmod
Return the tuple (x//y, x%y).

e

Ellipsis
The same as the ellipsis literal “...”, an object frequently used to indicate that something is omitted.
EncodingWarning
Base class for warnings about encodings.
enumerate
Return an enumerate object.
EnvironmentError
Base class for I/O related errors.
EOFError
Read beyond end of file.
eval
Evaluate the given source in the context of globals and locals.
Exception
Common base class for all non-exit exceptions.
ExceptionGroup
Both of these exception types wrap the exceptions in the sequence excs.
exec
Execute the given source in the context of globals and locals.
exit
Objects that when printed, print a message like “Use quit() or Ctrl-D (i.e.

f

False
The false value of the bool type.
file.close
Flush any buffers and close the underlying file.
file.read
Retrieve up to size data from the file.
file.write
Store data to the file.
FileExistsError
File already exists.
FileNotFoundError
File not found.
filter
Return an iterator yielding those items of iterable for which function(item) is true.
float
Convert a string or number to a floating-point number, if possible.
FloatingPointError
Floating-point operation failed.
format
Return type(value).__format__(value, format_spec)
frame.clear
This method clears all references to local variables held by the frame.
frame.f_back
Points to the previous stack frame (towards the caller), or None if this is the bottom stack frame
frame.f_builtins
The dictionary used by the frame to look up built-in (intrinsic) names
frame.f_code
The code object being executed in this frame.
frame.f_generator
The generator or coroutine object that owns this frame, or None if the frame is a normal function.
frame.f_globals
The dictionary used by the frame to look up global variables
frame.f_lasti
The “precise instruction” of the frame object (this is an index into the bytecode string of the code object)
frame.f_lineno
The current line number of the frame – writing to this from within a trace function jumps to the given line (only for the bottom-most frame).
frame.f_locals
The mapping used by the frame to look up local variables.
frame.f_trace
If not None, this is a function called for various events during code execution (this is used by debuggers).
frame.f_trace_lines
Set this attribute to False to disable triggering a tracing event for each source line.
frame.f_trace_opcodes
Set this attribute to True to allow per-opcode events to be requested.
frozendict
object's (key, value) pairs frozendict(iterable) -> new immutable dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v d = frozendict(d) frozendict(**kwargs) -> new immutable dicti…
frozenset
Build an immutable unordered collection of unique elements.
function.__annotate__
The annotate function for this function, or None if the function has no annotations.
function.__annotations__
A dictionary containing annotations of parameters.
function.__builtins__
A reference to the dictionary that holds the function’s builtins namespace.
function.__closure__
None or a tuple of cells that contain bindings for the names specified in the co_freevars attribute of the function’s code object.
function.__code__
The code object representing the compiled function body.
function.__defaults__
A tuple containing default parameter values for those parameters that have defaults, or None if no parameters have a default value.
function.__dict__
The namespace supporting arbitrary function attributes.
function.__doc__
The function’s documentation string, or None if unavailable.
function.__globals__
A reference to the dictionary that holds the function’s global variables – the global namespace of the module in which the function was defined.
function.__kwdefaults__
A dictionary containing defaults for keyword-only parameters.
function.__module__
The name of the module the function was defined in, or None if unavailable.
function.__name__
The function’s name.
function.__qualname__
The function’s qualified name.
function.__type_params__
A tuple containing the type parameters of a generic function.
FutureWarning
Base class for warnings about constructs that will change semantically in the future.

g

generator.__next__
Starts the execution of a generator function or resumes it at the yield expression where the function is currently suspended.
generator.close
Raises a GeneratorExit exception at the point where the generator function is currently suspended (equivalent to calling throw(GeneratorExit)).
generator.send
“Sends” a value into the generator function: the value argument becomes the result of the current yield expression.
generator.throw
Raises an exception at the point where the generator is currently suspended.
GeneratorExit
Request that a generator exit.
genericalias.__args__
This attribute is a tuple (possibly of length 1) of generic types passed to the original __class_getitem__() of the generic class:
genericalias.__origin__
This attribute points at the non-parameterized generic class:
genericalias.__parameters__
This attribute is a lazily computed tuple (possibly empty) of unique type variables found in __args__:
genericalias.__unpacked__
A boolean that is true if the alias has been unpacked using the * operator (see TypeVarTuple).
getattr
Get a named attribute from an object.
globals
Return the dictionary containing the current scope's global variables.

h

hasattr
Return whether the object has an attribute with the given name.
hash
Return the integer hash value for the given object.
help
Invoke the built-in help system.
hex
Return the hexadecimal representation of an integer.

i

id
Return the identity of an object.
ImportCycleError
Import produces a cycle.
ImportError
Import can't find module, or can't find name in module.
ImportWarning
Base class for warnings about probable mistakes in module imports
IndentationError
Improper indentation.
IndexError
Sequence index out of range.
input
Read a string from standard input.
int
Convert a number or string to an integer, or return 0 if no arguments are given.
InterruptedError
Interrupted by signal.
IOError
Base class for I/O related errors.
IsADirectoryError
Operation doesn't work on directories.
isinstance
Return whether an object is an instance of a class or of a subclass thereof.
issubclass
Return whether 'cls' is derived from another class or is the same class.
iter
Get an iterator from an object.
iterator.__iter__
Return the iterator object itself.
iterator.__next__
Return the next item from the iterator.

k

KeyboardInterrupt
Program interrupted by user.
KeyError
Mapping key not found.

l

len
Return the number of items in a container.
license
Object that when printed, prints the message “Type license() to see the full license text”, and when called, displays the full license text in a pager-like fashion (one screen at a time).
list
Built-in mutable sequence.
locals
Return a dictionary containing the current scope's local variables.
LookupError
Base class for lookup errors.

m

map
Make an iterator that computes the function using arguments from each of the iterables.
max
With a single iterable argument, return its biggest item.
MemoryError
Out of memory.
memoryview
Create a new memoryview object which references the given object.
method.__doc__
The method’s documentation (same as method.__func__.__doc__).
method.__func__
Refers to the original function object
method.__module__
The name of the module the method was defined in, or None if unavailable.
method.__name__
The name of the method (same as method.__func__.__name__)
method.__self__
Refers to the class instance object to which the method is bound
min
With a single iterable argument, return its smallest item.
module.__all__
The public names defined by a module are determined by checking the module’s namespace for a variable named __all__; if defined, it must be a sequence of strings which are names defined or imported b…
module.__annotate__
The annotate function for this module, or None if the module has no annotations.
module.__annotations__
A dictionary containing variable annotations collected during module body execution.
module.__dict__
The module’s namespace as a dictionary object.
module.__doc__
The module’s documentation string, or None if unavailable.
module.__file__
__file__ is an optional attribute that may or may not be set.
module.__lazy_modules__
A container (an object implementing __contains__()) of fully qualified module name strings.
module.__loader__
The loader object that the import machinery used to load the module.
module.__name__
The name used to uniquely identify the module in the import system.
module.__package__
The package a module belongs to.
module.__path__
A (possibly empty) sequence of strings enumerating the locations where the package’s submodules will be found.
module.__spec__
A record of the module’s import-system-related state.
module.__test__
In addition, there are cases when you want tests to be part of a module but not part of the help text, which requires that the tests not be included in the docstring.
ModuleNotFoundError
Module not found.

n

NameError
Name not found globally.
next
Return the next item from the iterator.
None
An object frequently used to represent the absence of a value, as when default arguments are not passed to a function.
NotADirectoryError
Operation only works on directories.
NotImplemented
A special value which should be returned by the binary special methods (e.g.
NotImplementedError
Method or function hasn't been implemented yet.

o

object
The base class of the class hierarchy.
oct
Return the octal representation of an integer.
open
Open file and return a stream.
ord
Return the ordinal value of a character.
OSError
Base class for I/O related errors.
OverflowError
Result too large to be represented.

p

PendingDeprecationWarning
Base class for warnings about features which will be deprecated in the future.
PermissionError
Not enough permissions.
pow
Equivalent to base**exp with 2 arguments or base**exp % mod with 3 arguments
print
Prints the values to a stream, or to sys.stdout by default.
ProcessLookupError
Process not found.
property
Return a property attribute.
PythonFinalizationError
Operation blocked during Python finalization.

q

quit
Objects that when printed, print a message like “Use quit() or Ctrl-D (i.e.

r

range
Return an object that produces a sequence of integers from start (inclusive) to stop (exclusive) by step.
RecursionError
Recursion limit exceeded.
ReferenceError
Weak ref proxy used after referent went away.
repr
Return the canonical string representation of the object.
ResourceWarning
Base class for warnings about resource usage.
reversed
Return a reverse iterator over the values of the given sequence.
round
Round a number to a given precision in decimal digits.
RuntimeError
Unspecified run-time error.
RuntimeWarning
Base class for warnings about dubious runtime behavior.

s

sentinel
Create a unique sentinel object with the given name.
sequence.append
Append value to the end of the sequence.
sequence.clear
Remove all items from sequence.
sequence.copy
Create a shallow copy of sequence.
sequence.count
Return the total number of occurrences of value in sequence.
sequence.extend
Extend sequence with the contents of iterable.
sequence.index
Return the index of the first occurrence of value in sequence.
sequence.insert
Insert value into sequence at the given index.
sequence.pop
Retrieve the item at index and also remove it from sequence.
sequence.remove
Remove the first item from sequence where sequence[i] == value.
sequence.reverse
Reverse the items of sequence in place.
set
Build an unordered collection of unique elements.
setattr
Sets the named attribute on the given object to the specified value.
slice
Create a slice object.
sorted
Return a new list containing all items from the iterable in ascending order.
staticmethod
Convert a function to be a static method.
StopAsyncIteration
Signal the end from iterator.__anext__().
StopIteration
Signal the end from iterator.__next__().
str
Create a new string object from the given object.
sum
Return the sum of a 'start' value (default: 0) plus an iterable of numbers
super
Typical use to call a cooperative superclass method: class C(B): def meth(self, arg): super().meth(arg) This works for class methods too: class C(B): @classmethod def cmeth(cls, arg): super().cmeth(a…
SyntaxError
Invalid syntax.
SyntaxWarning
Base class for warnings about dubious syntax.
SystemError
Internal error in the Python interpreter.
SystemExit
Request to exit from the interpreter.

t

TabError
Improper mixture of spaces and tabs.
TimeoutError
Timeout expired.
True
The true value of the bool type.
tuple
Built-in immutable sequence.
type
With one argument, return the type of an object.
TypeError
Inappropriate argument type.

u

UnboundLocalError
Local name referenced but not bound to a value.
UnicodeDecodeError
Unicode decoding error.
UnicodeEncodeError
Unicode encoding error.
UnicodeError
Unicode related error.
UnicodeTranslateError
Unicode translation error.
UnicodeWarning
Base class for warnings about Unicode related problems, mostly related to conversion problems.
UserWarning
Base class for warnings generated by user code.

v

ValueError
Inappropriate argument value (of correct type).
vars
Without arguments, equivalent to locals().

w

Warning
Base class for warning categories.
WindowsError
Only available on Windows.

z

ZeroDivisionError
Second argument to a division or modulo operation was zero.
zip
The zip object yields n-length tuples, where n is the number of iterables passed as positional arguments to zip().