0% found this document useful (0 votes)
2 views118 pages

Comprehensive Python Guide

The document provides comprehensive documentation for Python modules, specifically the 'math' and 'sys' modules. The 'math' module includes various mathematical functions and constants, while the 'sys' module offers access to interpreter-related objects and functions. Each module is accompanied by a reference link for further details and a list of available functions and their descriptions.

Uploaded by

n9hr8r4g6m
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views118 pages

Comprehensive Python Guide

The document provides comprehensive documentation for Python modules, specifically the 'math' and 'sys' modules. The 'math' module includes various mathematical functions and constants, while the 'sys' module offers access to interpreter-related objects and functions. Each module is accompanied by a reference link for further details and a list of available functions and their descriptions.

Uploaded by

n9hr8r4g6m
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Comprehensive Python Modules

Documentation
Python Library Documentation: module math

NAME
math

MODULE REFERENCE
[Link]

The following documentation is automatically generated from the Python


source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.

DESCRIPTION
This module provides access to the mathematical functions
defined by the C standard.

FUNCTIONS
acos(x, /)
Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

acosh(x, /)
Return the inverse hyperbolic cosine of x.

asin(x, /)
Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

asinh(x, /)
Return the inverse hyperbolic sine of x.

atan(x, /)
Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

atan2(y, x, /)
Return the arc tangent (measured in radians) of y/x.

Unlike atan(y/x), the signs of both x and y are considered.

atanh(x, /)
Return the inverse hyperbolic tangent of x.

ceil(x, /)
Return the ceiling of x as an Integral.

This is the smallest integer >= x.

comb(n, k, /)
Number of ways to choose k items from n items without repetition and
without order.

Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates


to zero when k > n.

Also called the binomial coefficient because it is equivalent


to the coefficient of k-th term in polynomial expansion of the
expression (1 + x)**n.

Raises TypeError if either of the arguments are not integers.


Raises ValueError if either of the arguments are negative.

copysign(x, y, /)
Return a float with the magnitude (absolute value) of x but the sign
of y.

On platforms that support signed zeros, copysign(1.0, -0.0)


returns -1.0.

cos(x, /)
Return the cosine of x (measured in radians).

cosh(x, /)
Return the hyperbolic cosine of x.

degrees(x, /)
Convert angle x from radians to degrees.

dist(p, q, /)
Return the Euclidean distance between two points p and q.

The points should be specified as sequences (or iterables) of


coordinates. Both inputs must have the same dimension.
Roughly equivalent to:
sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))

erf(x, /)
Error function at x.

erfc(x, /)
Complementary error function at x.

exp(x, /)
Return e raised to the power of x.

expm1(x, /)
Return exp(x)-1.

This function avoids the loss of precision involved in the direct


evaluation of exp(x)-1 for small x.

fabs(x, /)
Return the absolute value of the float x.

factorial(x, /)
Find x!.

Raise a ValueError if x is negative or non-integral.

floor(x, /)
Return the floor of x as an Integral.

This is the largest integer <= x.

fmod(x, y, /)
Return fmod(x, y), according to platform C.

x % y may differ.

frexp(x, /)
Return the mantissa and exponent of x, as pair (m, e).

m is a float and e is an int, such that x = m * 2.**e.


If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.

fsum(seq, /)
Return an accurate floating point sum of values in the iterable seq.

Assumes IEEE-754 floating point arithmetic.

gamma(x, /)
Gamma function at x.

gcd(*integers)
Greatest Common Divisor.

hypot(...)
hypot(*coordinates) -> value

Multidimensional Euclidean distance from the origin to a point.

Roughly equivalent to:


sqrt(sum(x**2 for x in coordinates))

For a two dimensional point (x, y), gives the hypotenuse


using the Pythagorean theorem: sqrt(x*x + y*y).

For example, the hypotenuse of a 3/4/5 right triangle is:

>>> hypot(3.0, 4.0)


5.0

isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)


Determine whether two floating point numbers are close in value.

rel_tol
maximum difference for being considered "close", relative to the
magnitude of the input values
abs_tol
maximum difference for being considered "close", regardless of the
magnitude of the input values

Return True if a is close in value to b, and False otherwise.

For the values to be considered close, the difference between them


must be smaller than at least one of the tolerances.

-inf, inf and NaN behave similarly to the IEEE 754 Standard. That
is, NaN is not close to anything, even itself. inf and -inf are
only close to themselves.

isfinite(x, /)
Return True if x is neither an infinity nor a NaN, and False
otherwise.

isinf(x, /)
Return True if x is a positive or negative infinity, and False
otherwise.
isnan(x, /)
Return True if x is a NaN (not a number), and False otherwise.

isqrt(n, /)
Return the integer part of the square root of the input.

lcm(*integers)
Least Common Multiple.

ldexp(x, i, /)
Return x * (2**i).

This is essentially the inverse of frexp().

lgamma(x, /)
Natural logarithm of absolute value of Gamma function at x.

log(...)
log(x, [base=math.e])
Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of


x.

log10(x, /)
Return the base 10 logarithm of x.

log1p(x, /)
Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

log2(x, /)
Return the base 2 logarithm of x.

modf(x, /)
Return the fractional and integer parts of x.

Both results carry the sign of x and are floats.

nextafter(x, y, /)
Return the next floating-point value after x towards y.

perm(n, k=None, /)
Number of ways to choose k items from n items without repetition and
with order.

Evaluates to n! / (n - k)! when k <= n and evaluates


to zero when k > n.

If k is not specified or is None, then k defaults to n


and the function returns n!.

Raises TypeError if either of the arguments are not integers.


Raises ValueError if either of the arguments are negative.

pow(x, y, /)
Return x**y (x to the power of y).

prod(iterable, /, *, start=1)
Calculate the product of all the elements in the input iterable.

The default start value for the product is 1.

When the iterable is empty, return the start value. This function is
intended specifically for use with numeric values and may reject
non-numeric types.

radians(x, /)
Convert angle x from degrees to radians.

remainder(x, y, /)
Difference between x and the closest integer multiple of y.

Return x - n*y where n*y is the closest integer multiple of y.


In the case where x is exactly halfway between two multiples of
y, the nearest even value of n is used. The result is always exact.

sin(x, /)
Return the sine of x (measured in radians).

sinh(x, /)
Return the hyperbolic sine of x.

sqrt(x, /)
Return the square root of x.

tan(x, /)
Return the tangent of x (measured in radians).

tanh(x, /)
Return the hyperbolic tangent of x.

trunc(x, /)
Truncates the Real x to the nearest Integral toward 0.
Uses the __trunc__ magic method.

ulp(x, /)
Return the value of the least significant bit of the float x.

DATA
e = 2.718281828459045
inf = inf
nan = nan
pi = 3.141592653589793
tau = 6.283185307179586

FILE
/usr/local/lib/python3.10/lib-dynload/[Link]-310-x86_64-[Link]

Python Library Documentation: built-in module sys

NAME
sys

MODULE REFERENCE
[Link]

The following documentation is automatically generated from the Python


source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.

DESCRIPTION
This module provides access to some objects used or maintained by the
interpreter and to functions that interact strongly with the interpreter.

Dynamic objects:

argv -- command line arguments; argv[0] is the script pathname if known


path -- module search path; path[0] is the script directory, else ''
modules -- dictionary of loaded modules

displayhook -- called to show results in an interactive session


excepthook -- called to handle any uncaught exception other than
SystemExit
To customize printing in an interactive session or to install a custom
top-level exception handler, assign other functions to replace these.

stdin -- standard input file object; used by input()


stdout -- standard output file object; used by print()
stderr -- standard error object; used for error messages
By assigning other file objects (or objects that behave like files)
to these, it is possible to redirect all of the interpreter's I/O.

last_type -- type of last uncaught exception


last_value -- value of last uncaught exception
last_traceback -- traceback of last uncaught exception
These three are only available in an interactive session after a
traceback has been printed.

Static objects:

builtin_module_names -- tuple of module names built into this interpreter


copyright -- copyright notice pertaining to this interpreter
exec_prefix -- prefix used to find the machine-specific Python library
executable -- absolute path of the executable binary of the Python
interpreter
float_info -- a named tuple with information about the float
implementation.
float_repr_style -- string indicating the style of repr() output for
floats
hash_info -- a named tuple with information about the hash algorithm.
hexversion -- version information encoded as a single integer
implementation -- Python implementation information.
int_info -- a named tuple with information about the int implementation.
maxsize -- the largest supported length of containers.
maxunicode -- the value of the largest Unicode code point
platform -- platform identifier
prefix -- prefix used to find the Python library
thread_info -- a named tuple with information about the thread
implementation.
version -- the version of this interpreter as a string
version_info -- version information as a named tuple
__stdin__ -- the original stdin; don't touch!
__stdout__ -- the original stdout; don't touch!
__stderr__ -- the original stderr; don't touch!
__displayhook__ -- the original displayhook; don't touch!
__excepthook__ -- the original excepthook; don't touch!

Functions:

displayhook() -- print an object to the screen, and save it in builtins._


excepthook() -- print an exception and its traceback to [Link]
exc_info() -- return thread-safe information about the current exception
exit() -- exit the interpreter by raising SystemExit
getdlopenflags() -- returns flags to be used for dlopen() calls
getprofile() -- get the global profiling function
getrefcount() -- return the reference count for an object (plus one :-)
getrecursionlimit() -- return the max recursion depth for the interpreter
getsizeof() -- return the size of an object in bytes
gettrace() -- get the global debug tracing function
setdlopenflags() -- set the flags to be used for dlopen() calls
setprofile() -- set the global profiling function
setrecursionlimit() -- set the max recursion depth for the interpreter
settrace() -- set the global debug tracing function

FUNCTIONS
__breakpointhook__ = breakpointhook(...)
breakpointhook(*args, **kws)

This hook function is called by built-in breakpoint().

__displayhook__ = displayhook(object, /)
Print an object to [Link] and also save it in builtins._

__excepthook__ = excepthook(exctype, value, traceback, /)


Handle an exception by displaying it with a traceback on [Link].

__unraisablehook__ = unraisablehook(unraisable, /)
Handle an unraisable exception.

The unraisable argument has the following attributes:

* exc_type: Exception type.


* exc_value: Exception value, can be None.
* exc_traceback: Exception traceback, can be None.
* err_msg: Error message, can be None.
* object: Object causing the exception, can be None.

addaudithook(hook)
Adds a new audit hook callback.

audit(...)
audit(event, *args)

Passes the event to any audit hooks that are attached.

breakpointhook(...)
breakpointhook(*args, **kws)

This hook function is called by built-in breakpoint().

call_tracing(func, args, /)
Call func(*args), while tracing is enabled.
The tracing state is saved, and restored afterwards. This is intended
to be called from a debugger from a checkpoint, to recursively debug
some other code.

displayhook(object, /)
Print an object to [Link] and also save it in builtins._

exc_info()
Return current exception information: (type, value, traceback).

Return information about the most recent exception caught by an except


clause in the current stack frame or in an older stack frame.

exit(status=None, /)
Exit the interpreter by raising SystemExit(status).

If the status is omitted or None, it defaults to zero (i.e., success).


If the status is an integer, it will be used as the system exit
status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).

get_asyncgen_hooks()
Return the installed asynchronous generators hooks.

This returns a namedtuple of the form (firstiter, finalizer).

get_coroutine_origin_tracking_depth()
Check status of origin tracking for coroutine objects in this thread.

get_int_max_str_digits()
Return the maximum string digits limit for non-binary int<->str
conversions.

getallocatedblocks()
Return the number of memory blocks currently allocated.

getdefaultencoding()
Return the current default encoding used by the Unicode
implementation.

getdlopenflags()
Return the current value of the flags that are used for dlopen calls.

The flag constants are defined in the os module.

getfilesystemencodeerrors()
Return the error mode used Unicode to OS filename conversion.
getfilesystemencoding()
Return the encoding used to convert Unicode filenames to OS filenames.

getprofile()
Return the profiling function set with [Link].

See the profiler chapter in the library manual.

getrecursionlimit()
Return the current value of the recursion limit.

The recursion limit is the maximum depth of the Python interpreter


stack. This limit prevents infinite recursion from causing an
overflow
of the C stack and crashing Python.

getrefcount(object, /)
Return the reference count of object.

The count returned is generally one higher than you might expect,
because it includes the (temporary) reference as an argument to
getrefcount().

getsizeof(...)
getsizeof(object [, default]) -> int

Return the size of object in bytes.

getswitchinterval()
Return the current thread switch interval; see
[Link]().

gettrace()
Return the global debug tracing function set with [Link].

See the debugger chapter in the library manual.

intern(string, /)
``Intern'' the given string.

This enters the string in the (global) table of interned strings whose
purpose is to speed up dictionary lookups. Return the string itself or
the previously interned string object with the same value.

is_finalizing()
Return True if Python is exiting.
set_asyncgen_hooks(...)
set_asyncgen_hooks(* [, firstiter] [, finalizer])

Set a finalizer for async generators objects.

set_coroutine_origin_tracking_depth(depth)
Enable or disable origin tracking for coroutine objects in this
thread.

Coroutine objects will track 'depth' frames of traceback information


about where they came from, available in their cr_origin attribute.

Set a depth of 0 to disable.

set_int_max_str_digits(maxdigits)
Set the maximum string digits limit for non-binary int<->str
conversions.

setdlopenflags(flags, /)
Set the flags used by the interpreter for dlopen calls.

This is used, for example, when the interpreter loads extension


modules. Among other things, this will enable a lazy resolving of
symbols when importing a module, if called as [Link](0).
To share symbols across extension modules, call as
[Link](os.RTLD_GLOBAL). Symbolic names for the flag
modules can be found in the os module (RTLD_xxx constants, e.g.
os.RTLD_LAZY).

setprofile(...)
setprofile(function)

Set the profiling function. It will be called on each function call


and return. See the profiler chapter in the library manual.

setrecursionlimit(limit, /)
Set the maximum depth of the Python interpreter stack to n.

This limit prevents infinite recursion from causing an overflow of the


C
stack and crashing Python. The highest possible limit is platform-
dependent.

setswitchinterval(interval, /)
Set the ideal thread switching delay inside the Python interpreter.

The actual frequency of switching threads can be lower if the


interpreter executes long sequences of uninterruptible code
(this is implementation-specific and workload-dependent).

The parameter must represent the desired switching delay in seconds


A typical value is 0.005 (5 milliseconds).

settrace(...)
settrace(function)

Set the global debug tracing function. It will be called on each


function call. See the debugger chapter in the library manual.

unraisablehook(unraisable, /)
Handle an unraisable exception.

The unraisable argument has the following attributes:

* exc_type: Exception type.


* exc_value: Exception value, can be None.
* exc_traceback: Exception traceback, can be None.
* err_msg: Error message, can be None.
* object: Object causing the exception, can be None.

DATA
__stderr__ = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf...
__stdin__ = <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8...
__stdout__ = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf...
abiflags = ''
api_version = 1013
argv = ['/usr/bin/entry/entry_point']
base_exec_prefix = '/usr/local'
base_prefix = '/usr/local'
builtin_module_names = ('_abc', '_ast', '_codecs', '_collections', '_f...
byteorder = 'little'
copyright = 'Copyright (c) 2001-2023 Python Software Foundati...ematis...
dont_write_bytecode = False
exec_prefix = '/usr/local'
executable = '/usr/local/bin/python3'
flags = [Link](debug=0, inspect=0, interactive=0, opt..., warn_defa...
float_info = sys.float_info(max=1.7976931348623157e+308, max_...epsilo...
float_repr_style = 'short'
hash_info = sys.hash_info(width=64, modulus=2305843009213693...iphash2...
hexversion = 50991344
implementation = namespace(name='cpython', cache_tag='cpython-310...xv...
int_info = sys.int_info(bits_per_digit=30, sizeof_digit=4, ..._str_dig...
maxsize = 9223372036854775807
maxunicode = 1114111
meta_path = [<_distutils_hack.DistutilsMetaFinder object>, <class '_fr...
modules = {'PIL': <module 'PIL' from '/usr/local/lib/python3.10/site-p...
orig_argv = ['python3', '/usr/bin/entry/entry_point']
path = ['/usr/bin/entry', '/home/bard', '/usr/bin/entry', '/usr/local/...
path_hooks = [<class '[Link]'>, <function [Link]...
path_importer_cache = {'/home/bard': FileFinder('/home/bard'), '/usr/b...
platform = 'linux'
platlibdir = 'lib'
prefix = '/usr/local'
pycache_prefix = None
stderr = <__main__.Tee object>
stdin = <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>
stdlib_module_names = frozenset({'__future__', '_abc', '_aix_support',...
stdout = <__main__.Tee object>
thread_info = sys.thread_info(name='pthread', lock='semaphore', versio...
version = '3.10.16 (main, Apr 8 2025, 01:38:46) [GCC 12.2.0]'
version_info = sys.version_info(major=3, minor=10, micro=16, releasele...
warnoptions = []

FILE
(built-in)

Python Library Documentation: module os

NAME
os - OS routines for NT or Posix depending on what system we're on.

MODULE REFERENCE
[Link]

The following documentation is automatically generated from the Python


source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.

DESCRIPTION
This exports:
- all functions from posix or nt, e.g. unlink, stat, etc.
- [Link] is either posixpath or ntpath
- [Link] is either 'posix' or 'nt'
- [Link] is a string representing the current directory (always '.')
- [Link] is a string representing the parent directory (always '..')
- [Link] is the (or a most common) pathname separator ('/' or '\\')
- [Link] is the extension separator (always '.')
- [Link] is the alternate pathname separator (None or '/')
- [Link] is the component separator used in $PATH etc
- [Link] is the line separator in text files ('\r' or '\n' or
'\r\n')
- [Link] is the default search path for executables
- [Link] is the file path of the null device ('/dev/null', etc.)

Programs that import and use 'os' stand a better chance of being
portable between different platforms. Of course, they must then
only use functions that are defined by all platforms (e.g., unlink
and opendir), and leave all pathname manipulation to [Link]
(e.g., split and join).

CLASSES
[Link]([Link])
[Link]
[Link]
[Link]
[Link]([Link])
stat_result
statvfs_result
terminal_size
posix.sched_param
posix.times_result
posix.uname_result
posix.waitid_result

class DirEntry([Link])
| Methods defined here:
|
| __fspath__(self, /)
| Returns the path for the entry.
|
| __repr__(self, /)
| Return repr(self).
|
| inode(self, /)
| Return inode of the entry; cached per entry.
|
| is_dir(self, /, *, follow_symlinks=True)
| Return True if the entry is a directory; cached per entry.
|
| is_file(self, /, *, follow_symlinks=True)
| Return True if the entry is a file; cached per entry.
|
| is_symlink(self, /)
| Return True if the entry is a symbolic link; cached per entry.
|
| stat(self, /, *, follow_symlinks=True)
| Return stat_result object for the entry; cached per entry.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...) from [Link]
| See PEP 585
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| name
| the entry's base filename, relative to scandir() "path" argument
|
| path
| the entry's full path name; equivalent to
[Link](scandir_path, [Link])

error = class OSError(Exception)


| Base class for I/O related errors.
|
| Method resolution order:
| OSError
| Exception
| BaseException
| object
|
| Built-in subclasses:
| BlockingIOError
| ChildProcessError
| ConnectionError
| FileExistsError
| ... and 7 other subclasses
|
| Methods defined here:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce__(...)
| Helper for pickle.
|
| __str__(self, /)
| Return str(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| characters_written
|
| errno
| POSIX exception code
|
| filename
| exception filename
|
| filename2
| second exception filename
|
| strerror
| exception strerror
|
| ----------------------------------------------------------------------
| Methods inherited from BaseException:
|
| __delattr__(self, name, /)
| Implement delattr(self, name).
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __repr__(self, /)
| Return repr(self).
|
| __setattr__(self, name, value, /)
| Implement setattr(self, name, value).
|
| __setstate__(...)
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class sched_param([Link])
| sched_param(sched_priority)
|
| Currently has only one field: sched_priority
|
| sched_priority
| A scheduling parameter.
|
| Method resolution order:
| sched_param
| [Link]
| [Link]
|
| Methods defined here:
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| sched_priority
| the scheduling priority
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __match_args__ = ('sched_priority',)
|
| n_fields = 1
|
| n_sequence_fields = 1
|
| n_unnamed_fields = 0
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return value*self.
|
| count(self, value, /)
| Return number of occurrences of value.
|
| index(self, value, start=0, stop=9223372036854775807, /)
| Return first index of value.
|
| Raises ValueError if the value is not present.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585

class stat_result([Link])
| stat_result(iterable=(), /)
|
| stat_result: Result from stat, fstat, or lstat.
|
| This object may be accessed either as a tuple of
| (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
| or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and
so on.
|
| Posix/windows: If your platform supports st_blksize, st_blocks,
st_rdev,
| or st_flags, they are available as attributes only.
|
| See [Link] for more information.
|
| Method resolution order:
| stat_result
| [Link]
| [Link]
|
| Methods defined here:
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| st_atime
| time of last access
|
| st_atime_ns
| time of last access in nanoseconds
|
| st_blksize
| blocksize for filesystem I/O
|
| st_blocks
| number of blocks allocated
|
| st_ctime
| time of last change
|
| st_ctime_ns
| time of last change in nanoseconds
|
| st_dev
| device
|
| st_gid
| group ID of owner
|
| st_ino
| inode
|
| st_mode
| protection bits
|
| st_mtime
| time of last modification
|
| st_mtime_ns
| time of last modification in nanoseconds
|
| st_nlink
| number of hard links
|
| st_rdev
| device type (if inode device)
|
| st_size
| total size, in bytes
|
| st_uid
| user ID of owner
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __match_args__ = ('st_mode', 'st_ino', 'st_dev', 'st_nlink',
'st_uid',...
|
| n_fields = 19
|
| n_sequence_fields = 10
|
| n_unnamed_fields = 3
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return value*self.
|
| count(self, value, /)
| Return number of occurrences of value.
|
| index(self, value, start=0, stop=9223372036854775807, /)
| Return first index of value.
|
| Raises ValueError if the value is not present.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585

class statvfs_result([Link])
| statvfs_result(iterable=(), /)
|
| statvfs_result: Result from statvfs or fstatvfs.
|
| This object may be accessed either as a tuple of
| (bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flag,
namemax),
| or via the attributes f_bsize, f_frsize, f_blocks, f_bfree, and so on.
|
| See [Link] for more information.
|
| Method resolution order:
| statvfs_result
| [Link]
| [Link]
|
| Methods defined here:
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| f_bavail
|
| f_bfree
|
| f_blocks
|
| f_bsize
|
| f_favail
|
| f_ffree
|
| f_files
|
| f_flag
|
| f_frsize
|
| f_fsid
|
| f_namemax
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __match_args__ = ('f_bsize', 'f_frsize', 'f_blocks', 'f_bfree',
'f_bav...
|
| n_fields = 11
|
| n_sequence_fields = 10
|
| n_unnamed_fields = 0
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return value*self.
|
| count(self, value, /)
| Return number of occurrences of value.
|
| index(self, value, start=0, stop=9223372036854775807, /)
| Return first index of value.
|
| Raises ValueError if the value is not present.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585

class terminal_size([Link])
| terminal_size(iterable=(), /)
|
| A tuple of (columns, lines) for holding terminal window size
|
| Method resolution order:
| terminal_size
| [Link]
| [Link]
|
| Methods defined here:
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| columns
| width of the terminal window in characters
|
| lines
| height of the terminal window in characters
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __match_args__ = ('columns', 'lines')
|
| n_fields = 2
|
| n_sequence_fields = 2
|
| n_unnamed_fields = 0
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return value*self.
|
| count(self, value, /)
| Return number of occurrences of value.
|
| index(self, value, start=0, stop=9223372036854775807, /)
| Return first index of value.
|
| Raises ValueError if the value is not present.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585

class times_result([Link])
| times_result(iterable=(), /)
|
| times_result: Result from [Link]().
|
| This object may be accessed either as a tuple of
| (user, system, children_user, children_system, elapsed),
| or via the attributes user, system, children_user, children_system,
| and elapsed.
|
| See [Link] for more information.
|
| Method resolution order:
| times_result
| [Link]
| [Link]
|
| Methods defined here:
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| children_system
| system time of children
|
| children_user
| user time of children
|
| elapsed
| elapsed time since an arbitrary point in the past
|
| system
| system time
|
| user
| user time
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __match_args__ = ('user', 'system', 'children_user',
'children_system'...
|
| n_fields = 5
|
| n_sequence_fields = 5
|
| n_unnamed_fields = 0
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return value*self.
|
| count(self, value, /)
| Return number of occurrences of value.
|
| index(self, value, start=0, stop=9223372036854775807, /)
| Return first index of value.
|
| Raises ValueError if the value is not present.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585

class uname_result([Link])
| uname_result(iterable=(), /)
|
| uname_result: Result from [Link]().
|
| This object may be accessed either as a tuple of
| (sysname, nodename, release, version, machine),
| or via the attributes sysname, nodename, release, version, and
machine.
|
| See [Link] for more information.
|
| Method resolution order:
| uname_result
| [Link]
| [Link]
|
| Methods defined here:
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| machine
| hardware identifier
|
| nodename
| name of machine on network (implementation-defined)
|
| release
| operating system release
|
| sysname
| operating system name
|
| version
| operating system version
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __match_args__ = ('sysname', 'nodename', 'release', 'version',
'machin...
|
| n_fields = 5
|
| n_sequence_fields = 5
|
| n_unnamed_fields = 0
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return value*self.
|
| count(self, value, /)
| Return number of occurrences of value.
|
| index(self, value, start=0, stop=9223372036854775807, /)
| Return first index of value.
|
| Raises ValueError if the value is not present.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585

class waitid_result([Link])
| waitid_result(iterable=(), /)
|
| waitid_result: Result from waitid.
|
| This object may be accessed either as a tuple of
| (si_pid, si_uid, si_signo, si_status, si_code),
| or via the attributes si_pid, si_uid, and so on.
|
| See [Link] for more information.
|
| Method resolution order:
| waitid_result
| [Link]
| [Link]
|
| Methods defined here:
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| si_code
|
| si_pid
|
| si_signo
|
| si_status
|
| si_uid
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __match_args__ = ('si_pid', 'si_uid', 'si_signo', 'si_status',
'si_cod...
|
| n_fields = 5
|
| n_sequence_fields = 5
|
| n_unnamed_fields = 0
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return key in self.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmul__(self, value, /)
| Return value*self.
|
| count(self, value, /)
| Return number of occurrences of value.
|
| index(self, value, start=0, stop=9223372036854775807, /)
| Return first index of value.
|
| Raises ValueError if the value is not present.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585

FUNCTIONS
WCOREDUMP(status, /)
Return True if the process returning status was dumped to a core file.

WEXITSTATUS(status)
Return the process return code from status.

WIFCONTINUED(status)
Return True if a particular process was continued from a job control
stop.

Return True if the process returning status was continued from a


job control stop.

WIFEXITED(status)
Return True if the process returning status exited via the exit()
system call.
WIFSIGNALED(status)
Return True if the process returning status was terminated by a
signal.

WIFSTOPPED(status)
Return True if the process returning status was stopped.

WSTOPSIG(status)
Return the signal that stopped the process that provided the status
value.

WTERMSIG(status)
Return the signal that terminated the process that provided the status
value.

_exit(status)
Exit to the system with specified status, without normal exit
processing.

abort()
Abort the interpreter immediately.

This function 'dumps core' or otherwise fails in the hardest way


possible
on the hosting operating system. This function never returns.

access(path, mode, *, dir_fd=None, effective_ids=False,


follow_symlinks=True)
Use the real uid/gid to test for access to a path.

path
Path to be tested; can be string, bytes, or a path-like object.
mode
Operating-system mode bitfield. Can be F_OK to test existence,
or the inclusive-OR of R_OK, W_OK, and X_OK.
dir_fd
If not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that
directory.
effective_ids
If True, access will use the effective uid/gid instead of
the real uid/gid.
follow_symlinks
If False, and the last element of the path is a symbolic link,
access will examine the symbolic link itself instead of the file
the link points to.
dir_fd, effective_ids, and follow_symlinks may not be implemented
on your platform. If they are unavailable, using them will raise a
NotImplementedError.

Note that most operations will use the effective uid/gid, therefore
this
routine can be used in a suid/sgid environment to test if the
invoking user
has the specified access to the path.

chdir(path)
Change the current working directory to the specified path.

path may always be specified as a string.


On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.

chmod(path, mode, *, dir_fd=None, follow_symlinks=True)


Change the access permissions of a file.

path
Path to be modified. May always be specified as a str, bytes, or
a path-like object.
On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an
exception.
mode
Operating-system mode bitfield.
dir_fd
If not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that
directory.
follow_symlinks
If False, and the last element of the path is a symbolic link,
chmod will modify the symbolic link itself instead of the file
the link points to.

It is an error to use dir_fd or follow_symlinks when specifying path


as
an open file descriptor.
dir_fd and follow_symlinks may not be implemented on your platform.
If they are unavailable, using them will raise a
NotImplementedError.

chown(path, uid, gid, *, dir_fd=None, follow_symlinks=True)


Change the owner and group id of path to the numeric uid and gid.\
path
Path to be examined; can be string, bytes, a path-like object, or
open-file-descriptor int.
dir_fd
If not None, it should be a file descriptor open to a directory,
and path should be relative; path will then be relative to that
directory.
follow_symlinks
If False, and the last element of the path is a symbolic link,
stat will examine the symbolic link itself instead of the file
the link points to.

path may always be specified as a string.


On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.
If dir_fd is not None, it should be a file descriptor open to a
directory,
and path should be relative; path will then be relative to that
directory.
If follow_symlinks is False, and the last element of the path is a
symbolic
link, chown will modify the symbolic link itself instead of the file
the
link points to.
It is an error to use dir_fd or follow_symlinks when specifying path
as
an open file descriptor.
dir_fd and follow_symlinks may not be implemented on your platform.
If they are unavailable, using them will raise a
NotImplementedError.

chroot(path)
Change root directory to path.

close(fd)
Close a file descriptor.

closerange(fd_low, fd_high, /)
Closes all file descriptors in [fd_low, fd_high), ignoring errors.

confstr(name, /)
Return a string-valued system configuration variable.

copy_file_range(src, dst, count, offset_src=None, offset_dst=None)


Copy count bytes from one file descriptor to another.
src
Source file descriptor.
dst
Destination file descriptor.
count
Number of bytes to copy.
offset_src
Starting offset in src.
offset_dst
Starting offset in dst.

If offset_src is None, then src is read from the current position;


respectively for offset_dst.

cpu_count()
Return the number of CPUs in the system; return None if
indeterminable.

This number is not equivalent to the number of CPUs the current


process can
use. The number of usable CPUs can be obtained with
``len(os.sched_getaffinity(0))``

ctermid()
Return the name of the controlling terminal for this process.

device_encoding(fd)
Return a string describing the encoding of a terminal's file
descriptor.

The file descriptor must be attached to a terminal.


If the device is not a terminal, return None.

dup(fd, /)
Return a duplicate of a file descriptor.

dup2(fd, fd2, inheritable=True)


Duplicate file descriptor.

eventfd(initval, flags=524288)
Creates and returns an event notification file descriptor.

eventfd_read(fd)
Read eventfd value

eventfd_write(fd, value)
Write eventfd value.
execl(file, *args)
execl(file, *args)

Execute the executable file with argument list args, replacing the
current process.

execle(file, *args)
execle(file, *args, env)

Execute the executable file with argument list args and


environment env, replacing the current process.

execlp(file, *args)
execlp(file, *args)

Execute the executable file (which is searched for along $PATH)


with argument list args, replacing the current process.

execlpe(file, *args)
execlpe(file, *args, env)

Execute the executable file (which is searched for along $PATH)


with argument list args and environment env, replacing the current
process.

execv(path, argv, /)
Execute an executable path with arguments, replacing current process.

path
Path of executable file.
argv
Tuple or list of strings.

execve(path, argv, env)


Execute an executable path with arguments, replacing current process.

path
Path of executable file.
argv
Tuple or list of strings.
env
Dictionary of strings mapping to strings.

execvp(file, args)
execvp(file, args)

Execute the executable file (which is searched for along $PATH)


with argument list args, replacing the current process.
args may be a list or tuple of strings.

execvpe(file, args, env)


execvpe(file, args, env)

Execute the executable file (which is searched for along $PATH)


with argument list args and environment env, replacing the
current process.
args may be a list or tuple of strings.

fchdir(fd)
Change to the directory of the given file descriptor.

fd must be opened on a directory, not a file.


Equivalent to [Link](fd).

fchmod(fd, mode)
Change the access permissions of the file given by file descriptor fd.

Equivalent to [Link](fd, mode).

fchown(fd, uid, gid)


Change the owner and group id of the file specified by file
descriptor.

Equivalent to [Link](fd, uid, gid).

fdatasync(fd)
Force write of fd to disk without forcing update of metadata.

fdopen(fd, mode='r', buffering=-1, encoding=None, *args, **kwargs)


# Supply [Link]()

fork()
Fork a child process.

Return 0 to child process and PID of child to parent process.

forkpty()
Fork a new process with a new pseudo-terminal as controlling tty.

Returns a tuple of (pid, master_fd).


Like fork(), return pid of 0 to the child process,
and pid of child to the parent process.
To both, return fd of newly opened pseudo-terminal.

fpathconf(fd, name, /)
Return the configuration limit name for the file descriptor fd.
If there is no limit, return -1.

fsdecode(filename)
Decode filename (an [Link], bytes, or str) from the filesystem
encoding with 'surrogateescape' error handler, return str unchanged.
On
Windows, use 'strict' error handler if the file system encoding is
'mbcs' (which is the default encoding).

fsencode(filename)
Encode filename (an [Link], bytes, or str) to the filesystem
encoding with 'surrogateescape' error handler, return bytes unchanged.
On Windows, use 'strict' error handler if the file system encoding is
'mbcs' (which is the default encoding).

fspath(path)
Return the file system path representation of the object.

If the object is str or bytes, then allow it to pass through as-is. If


the
object defines __fspath__(), then return the result of that method.
All other
types raise a TypeError.

fstat(fd)
Perform a stat system call on the given file descriptor.

Like stat(), but for an open file descriptor.


Equivalent to [Link](fd).

fstatvfs(fd, /)
Perform an fstatvfs system call on the given fd.

Equivalent to statvfs(fd).

fsync(fd)
Force write of fd to disk.

ftruncate(fd, length, /)
Truncate a file, specified by file descriptor, to a specific length.

fwalk(top='.', topdown=True, onerror=None, *, follow_symlinks=False,


dir_fd=None)
Directory tree generator.

This behaves exactly like walk(), except that it yields a 4-tuple


dirpath, dirnames, filenames, dirfd

`dirpath`, `dirnames` and `filenames` are identical to walk() output,


and `dirfd` is a file descriptor referring to the directory `dirpath`.

The advantage of fwalk() over walk() is that it's safe against symlink
races (when follow_symlinks is False).

If dir_fd is not None, it should be a file descriptor open to a


directory,
and top should be relative; top will then be relative to that
directory.
(dir_fd is always supported for fwalk.)

Caution:
Since fwalk() yields file descriptors, those are only valid until the
next iteration step, so you should dup() them if you want to keep them
for a longer period.

Example:

import os
for root, dirs, files, rootfd in [Link]('python/Lib/email'):
print(root, "consumes", end="")
print(sum([Link](name, dir_fd=rootfd).st_size for name in files),
end="")
print("bytes in", len(files), "non-directory files")
if 'CVS' in dirs:
[Link]('CVS') # don't visit CVS directories

get_blocking(fd, /)
Get the blocking mode of the file descriptor.

Return False if the O_NONBLOCK flag is set, True if the flag is


cleared.

get_exec_path(env=None)
Returns the sequence of directories that will be searched for the
named executable (similar to a shell) when launching a process.

*env* must be an environment variable dict or None. If *env* is None,


[Link] will be used.

get_inheritable(fd, /)
Get the close-on-exe flag of the specified file descriptor.

get_terminal_size(...)
Return the size of the terminal window as (columns, lines).
The optional argument fd (default standard output) specifies
which file descriptor should be queried.

If the file descriptor is not connected to a terminal, an OSError


is thrown.

This function will only be defined if an implementation is


available for this system.

shutil.get_terminal_size is the high-level function which should


normally be used, os.get_terminal_size is the low-level
implementation.

getcwd()
Return a unicode string representing the current working directory.

getcwdb()
Return a bytes string representing the current working directory.

getegid()
Return the current process's effective group id.

getenv(key, default=None)
Get an environment variable, return None if it doesn't exist.
The optional second argument can specify an alternate default.
key, default and the result are str.

getenvb(key, default=None)
Get an environment variable, return None if it doesn't exist.
The optional second argument can specify an alternate default.
key, default and the result are bytes.

geteuid()
Return the current process's effective user id.

getgid()
Return the current process's group id.

getgrouplist(user, group, /)
Returns a list of groups to which a user belongs.

user
username to lookup
group
base group id of the user

getgroups()
Return list of supplemental group IDs for the process.

getloadavg()
Return average recent system load information.

Return the number of processes in the system run queue averaged over
the last 1, 5, and 15 minutes as a tuple of three floats.
Raises OSError if the load average was unobtainable.

getlogin()
Return the actual login name.

getpgid(pid)
Call the system call getpgid(), and return the result.

getpgrp()
Return the current process group id.

getpid()
Return the current process id.

getppid()
Return the parent's process id.

If the parent process has already exited, Windows machines will still
return its id; others systems will return the id of the 'init' process
(1).

getpriority(which, who)
Return program scheduling priority.

getrandom(size, flags=0)
Obtain a series of random bytes.

getresgid()
Return a tuple of the current process's real, effective, and saved
group ids.

getresuid()
Return a tuple of the current process's real, effective, and saved
user ids.

getsid(pid, /)
Call the system call getsid(pid) and return the result.

getuid()
Return the current process's user id.
getxattr(path, attribute, *, follow_symlinks=True)
Return the value of extended attribute attribute on path.

path may be either a string, a path-like object, or an open file


descriptor.
If follow_symlinks is False, and the last element of the path is a
symbolic
link, getxattr will examine the symbolic link itself instead of the
file
the link points to.

initgroups(username, gid, /)
Initialize the group access list.

Call the system initgroups() to initialize the group access list with
all of
the groups of which the specified username is a member, plus the
specified
group id.

isatty(fd, /)
Return True if the fd is connected to a terminal.

Return True if the file descriptor is an open file descriptor


connected to the slave end of a terminal.

kill(pid, signal, /)
Kill a process with a signal.

killpg(pgid, signal, /)
Kill a process group with a signal.

lchown(path, uid, gid)


Change the owner and group id of path to the numeric uid and gid.

This function will not follow symbolic links.


Equivalent to [Link](path, uid, gid, follow_symlinks=False).

link(src, dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True)


Create a hard link to a file.

If either src_dir_fd or dst_dir_fd is not None, it should be a file


descriptor open to a directory, and the respective path string (src
or dst)
should be relative; the path will then be relative to that
directory.
If follow_symlinks is False, and the last element of src is a symbolic
link, link will create a link to the symbolic link itself instead of
the
file the link points to.
src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on
your
platform. If they are unavailable, using them will raise a
NotImplementedError.

listdir(path=None)
Return a list containing the names of the files in the directory.

path can be specified as either str, bytes, or a path-like object. If


path is bytes,
the filenames returned will also be bytes; in all other
circumstances
the filenames returned will be str.
If path is None, uses the path='.'.
On some platforms, path may also be specified as an open file
descriptor;\
the file descriptor must refer to a directory.
If this functionality is unavailable, using it raises
NotImplementedError.

The list is in arbitrary order. It does not include the special


entries '.' and '..' even if they are present in the directory.

listxattr(path=None, *, follow_symlinks=True)
Return a list of extended attributes on path.

path may be either None, a string, a path-like object, or an open file


descriptor.
if path is None, listxattr will examine the current directory.
If follow_symlinks is False, and the last element of the path is a
symbolic
link, listxattr will examine the symbolic link itself instead of the
file
the link points to.

lockf(fd, command, length, /)


Apply, test or remove a POSIX lock on an open file descriptor.

fd
An open file descriptor.
command
One of F_LOCK, F_TLOCK, F_ULOCK or F_TEST.
length
The number of bytes to lock, starting at the current position.

lseek(fd, position, how, /)


Set the position of a file descriptor. Return the new position.

Return the new cursor position in number of bytes


relative to the beginning of the file.

lstat(path, *, dir_fd=None)
Perform a stat system call on the given path, without following
symbolic links.

Like stat(), but do not follow symbolic links.


Equivalent to stat(path, follow_symlinks=False).

major(device, /)
Extracts a device major number from a raw device number.

makedev(major, minor, /)
Composes a raw device number from the major and minor device numbers.

makedirs(name, mode=511, exist_ok=False)


makedirs(name [, mode=0o777][, exist_ok=False])

Super-mkdir; create a leaf directory and all intermediate ones. Works


like
mkdir, except that any intermediate path segment (not just the
rightmost)
will be created if it does not exist. If the target directory already
exists, raise an OSError if exist_ok is False. Otherwise no exception
is
raised. This is recursive.

memfd_create(name, flags=1)

minor(device, /)
Extracts a device minor number from a raw device number.

mkdir(path, mode=511, *, dir_fd=None)


Create a directory.

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

The mode argument is ignored on Windows. Where it is used, the current


umask
value is first masked out.
mkfifo(path, mode=438, *, dir_fd=None)
Create a "fifo" (a POSIX named pipe).

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

mknod(path, mode=384, device=0, *, dir_fd=None)


Create a node in the file system.

Create a node in the file system (file, device special file or named
pipe)
at path. mode specifies both the permissions to use and the
type of node to be created, being combined (bitwise OR) with one of
S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. If S_IFCHR or S_IFBLK is set
on mode,
device defines the newly created device special file (probably using
[Link]()). Otherwise device is ignored.

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

nice(increment, /)
Add increment to the priority of process and return the new priority.

open(path, flags, mode=511, *, dir_fd=None)


Open a file for low level IO. Returns a file descriptor (integer).

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

openpty()
Open a pseudo-terminal.

Return a tuple of (master_fd, slave_fd) containing open file


descriptors
for both the master and slave ends.

pathconf(path, name)
Return the configuration limit name for the file or directory path.

If there is no limit, return -1.


On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.

pidfd_open(pid, flags=0)
Return a file descriptor referring to the process *pid*.

The descriptor can be used to perform process management without races


and
signals.

pipe()
Create a pipe.

Returns a tuple of two file descriptors:


(read_fd, write_fd)

pipe2(flags, /)
Create a pipe with flags set atomically.

Returns a tuple of two file descriptors:


(read_fd, write_fd)

flags can be constructed by ORing together one or more of these


values:
O_NONBLOCK, O_CLOEXEC.

popen(cmd, mode='r', buffering=-1)


# Supply [Link]()

posix_fadvise(fd, offset, length, advice, /)


Announce an intention to access data in a specific pattern.

Announce an intention to access data in a specific pattern, thus


allowing
the kernel to make optimizations.
The advice applies to the region of the file specified by fd starting
at
offset and continuing for length bytes.
advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL,
POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, or
POSIX_FADV_DONTNEED.
posix_fallocate(fd, offset, length, /)
Ensure a file has allocated at least a particular number of bytes on
disk.

Ensure that the file specified by fd encompasses a range of bytes


starting at offset bytes from the beginning and continuing for length
bytes.

posix_spawn(...)
Execute the program specified by path in a new process.

path
Path of executable file.
argv
Tuple or list of strings.
env
Dictionary of strings mapping to strings.
file_actions
A sequence of file action tuples.
setpgroup
The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.
resetids
If the value is `true` the POSIX_SPAWN_RESETIDS will be activated.
setsid
If the value is `true` the POSIX_SPAWN_SETSID or
POSIX_SPAWN_SETSID_NP will be activated.
setsigmask
The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.
setsigdef
The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.
scheduler
A tuple with the scheduler policy (optional) and parameters.

posix_spawnp(...)
Execute the program specified by path in a new process.

path
Path of executable file.
argv
Tuple or list of strings.
env
Dictionary of strings mapping to strings.
file_actions
A sequence of file action tuples.
setpgroup
The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.
resetids
If the value is `True` the POSIX_SPAWN_RESETIDS will be activated.
setsid
If the value is `True` the POSIX_SPAWN_SETSID or
POSIX_SPAWN_SETSID_NP will be activated.
setsigmask
The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.
setsigdef
The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.
scheduler
A tuple with the scheduler policy (optional) and parameters.

pread(fd, length, offset, /)


Read a number of bytes from a file descriptor starting at a particular
offset.

Read length bytes from file descriptor fd, starting at offset bytes
from
the beginning of the file. The file offset remains unchanged.

preadv(fd, buffers, offset, flags=0, /)


Reads from a file descriptor into a number of mutable bytes-like
objects.

Combines the functionality of readv() and pread(). As readv(), it will


transfer data into each buffer until it is full and then move on to
the next
buffer in the sequence to hold the rest of the data. Its fourth
argument,
specifies the file offset at which the input operation is to be
performed. It
will return the total number of bytes read (which can be less than the
total
capacity of all the objects).

The flags argument contains a bitwise OR of zero or more of the


following flags:

- RWF_HIPRI
- RWF_NOWAIT

Using non-zero flags requires Linux 4.6 or newer.

putenv(name, value, /)
Change or add an environment variable.

pwrite(fd, buffer, offset, /)


Write bytes to a file descriptor starting at a particular offset.
Write buffer to fd, starting at offset bytes from the beginning of
the file. Returns the number of bytes writte. Does not change the
current file offset.

pwritev(fd, buffers, offset, flags=0, /)


Writes the contents of bytes-like objects to a file descriptor at a
given offset.

Combines the functionality of writev() and pwrite(). All buffers must


be a sequence
of bytes-like objects. Buffers are processed in array order. Entire
contents of first
buffer is written before proceeding to second, and so on. The
operating system may
set a limit (sysconf() value SC_IOV_MAX) on the number of buffers that
can be used.
This function writes the contents of each object to the file
descriptor and returns
the total number of bytes written.

The flags argument contains a bitwise OR of zero or more of the


following flags:

- RWF_DSYNC
- RWF_SYNC
- RWF_APPEND

Using non-zero flags requires Linux 4.7 or newer.

read(fd, length, /)
Read from a file descriptor. Returns a bytes object.

readlink(path, *, dir_fd=None)
Return a string representing the path to which the symbolic link
points.

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.

dir_fd may not be implemented on your platform. If it is unavailable,


using it will raise a NotImplementedError.

readv(fd, buffers, /)
Read from a file descriptor fd into an iterable of buffers.

The buffers should be mutable buffers accepting bytes.


readv will transfer data into each buffer until it is full
and then move on to the next buffer in the sequence to hold
the rest of the data.

readv returns the total number of bytes read,


which may be less than the total capacity of all the buffers.

register_at_fork(...)
Register callables to be called when forking a new process.

before
A callable to be called in the parent before the fork() syscall.
after_in_child
A callable to be called in the child after fork().
after_in_parent
A callable to be called in the parent after fork().

'before' callbacks are called in reverse order.


'after_in_child' and 'after_in_parent' callbacks are called in order.

remove(path, *, dir_fd=None)
Remove a file (same as unlink()).

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

removedirs(name)
removedirs(name)

Super-rmdir; remove a leaf directory and all empty intermediate


ones. Works like rmdir except that, if the leaf directory is
successfully removed, directories corresponding to rightmost path
segments will be pruned away until either the whole path is
consumed or an error occurs. Errors during this latter phase are
ignored -- they generally mean that a directory was not empty.

removexattr(path, attribute, *, follow_symlinks=True)


Remove extended attribute attribute on path.

path may be either a string, a path-like object, or an open file


descriptor.
If follow_symlinks is False, and the last element of the path is a
symbolic
link, removexattr will modify the symbolic link itself instead of
the file
the link points to.

rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)


Rename a file or directory.

If either src_dir_fd or dst_dir_fd is not None, it should be a file


descriptor open to a directory, and the respective path string (src
or dst)
should be relative; the path will then be relative to that
directory.
src_dir_fd and dst_dir_fd, may not be implemented on your platform.
If they are unavailable, using them will raise a
NotImplementedError.

renames(old, new)
renames(old, new)

Super-rename; create directories as necessary and delete any left


empty. Works like rename, except creation of any intermediate
directories needed to make the new pathname good is attempted
first. After the rename, directories corresponding to rightmost
path segments of the old name will be pruned until either the
whole path is consumed or a nonempty directory is found.

Note: this function can fail with the new directory structure made
if you lack permissions needed to unlink the leaf directory or
file.

replace(src, dst, *, src_dir_fd=None, dst_dir_fd=None)


Rename a file or directory, overwriting the destination.

If either src_dir_fd or dst_dir_fd is not None, it should be a file


descriptor open to a directory, and the respective path string (src
or dst)
should be relative; the path will then be relative to that
directory.
src_dir_fd and dst_dir_fd, may not be implemented on your platform.
If they are unavailable, using them will raise a
NotImplementedError.

rmdir(path, *, dir_fd=None)
Remove a directory.

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

scandir(path=None)
Return an iterator of DirEntry objects for given path.

path can be specified as either str, bytes, or a path-like object. If


path
is bytes, the names of yielded DirEntry objects will also be bytes; in
all other circumstances they will be str.

If path is None, uses the path='.'.

sched_get_priority_max(policy)
Get the maximum scheduling priority for policy.

sched_get_priority_min(policy)
Get the minimum scheduling priority for policy.

sched_getaffinity(pid, /)
Return the affinity of the process identified by pid (or the current
process if zero).

The affinity is returned as a set of CPU identifiers.

sched_getparam(pid, /)
Returns scheduling parameters for the process identified by pid.

If pid is 0, returns parameters for the calling process.


Return value is an instance of sched_param.

sched_getscheduler(pid, /)
Get the scheduling policy for the process identified by pid.

Passing 0 for pid returns the scheduling policy for the calling
process.

sched_rr_get_interval(pid, /)
Return the round-robin quantum for the process identified by pid, in
seconds.

Value returned is a float.

sched_setaffinity(pid, mask, /)
Set the CPU affinity of the process identified by pid to mask.

mask should be an iterable of integers identifying CPUs.


sched_setparam(pid, param, /)
Set scheduling parameters for the process identified by pid.

If pid is 0, sets parameters for the calling process.


param should be an instance of sched_param.

sched_setscheduler(pid, policy, param, /)


Set the scheduling policy for the process identified by pid.

If pid is 0, the calling process is changed.


param is an instance of sched_param.

sched_yield()
Voluntarily relinquish the CPU.

sendfile(out_fd, in_fd, offset, count)


Copy count bytes from file descriptor in_fd to file descriptor out_fd.

set_blocking(fd, blocking, /)
Set the blocking mode of the specified file descriptor.

Set the O_NONBLOCK flag if blocking is False,


clear the O_NONBLOCK flag otherwise.

set_inheritable(fd, inheritable, /)
Set the inheritable flag of the specified file descriptor.

setegid(egid, /)
Set the current process's effective group id.

seteuid(euid, /)
Set the current process's effective user id.

setgid(gid, /)
Set the current process's group id.

setgroups(groups, /)
Set the groups of the current process to list.

setpgid(pid, pgrp, /)
Call the system call setpgid(pid, pgrp).

setpgrp()
Make the current process the leader of its process group.

setpriority(which, who, priority)


Set program scheduling priority.
setregid(rgid, egid, /)
Set the current process's real and effective group ids.

setresgid(rgid, egid, sgid, /)


Set the current process's real, effective, and saved group ids.

setresuid(ruid, euid, suid, /)


Set the current process's real, effective, and saved user ids.

setreuid(ruid, euid, /)
Set the current process's real and effective user ids.

setsid()
Call the system call setsid().

setuid(uid, /)
Set the current process's user id.

setxattr(path, attribute, value, flags=0, *, follow_symlinks=True)


Set extended attribute attribute on path to value.

path may be either a string, a path-like object, or an open file


descriptor.
If follow_symlinks is False, and the last element of the path is a
symbolic
link, setxattr will modify the symbolic link itself instead of the
file
the link points to.

spawnl(mode, file, *args)


spawnl(mode, file, *args) -> integer

Execute file with arguments from args in a subprocess.


If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

spawnle(mode, file, *args)


spawnle(mode, file, *args, env) -> integer

Execute file with arguments from args in a subprocess with the


supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

spawnlp(mode, file, *args)


spawnlp(mode, file, *args) -> integer
Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

spawnlpe(mode, file, *args)


spawnlpe(mode, file, *args, env) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

spawnv(mode, file, args)


spawnv(mode, file, args) -> integer

Execute file with arguments from args in a subprocess.


If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

spawnve(mode, file, args, env)


spawnve(mode, file, args, env) -> integer

Execute file with arguments from args in a subprocess with the


specified environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

spawnvp(mode, file, args)


spawnvp(mode, file, args) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

spawnvpe(mode, file, args, env)


spawnvpe(mode, file, args, env) -> integer

Execute file (which is looked for along $PATH) with arguments from
args in a subprocess with the supplied environment.
If mode == P_NOWAIT return the pid of the process.
If mode == P_WAIT return the process's exit code if it exits normally;
otherwise return -SIG, where SIG is the signal that killed it.

splice(src, dst, count, offset_src=None, offset_dst=None, flags=0)


Transfer count bytes from one pipe to a descriptor or vice versa.

src
Source file descriptor.
dst
Destination file descriptor.
count
Number of bytes to copy.
offset_src
Starting offset in src.
offset_dst
Starting offset in dst.
flags
Flags to modify the semantics of the call.

If offset_src is None, then src is read from the current position;


respectively for offset_dst. The offset associated to the file
descriptor that refers to a pipe must be None.

stat(path, *, dir_fd=None, follow_symlinks=True)


Perform a stat system call on the given path.

path
Path to be examined; can be string, bytes, a path-like object or
open-file-descriptor int.
dir_fd
If not None, it should be a file descriptor open to a directory,
and path should be a relative string; path will then be relative
to
that directory.
follow_symlinks
If False, and the last element of the path is a symbolic link,
stat will examine the symbolic link itself instead of the file
the link points to.

dir_fd and follow_symlinks may not be implemented


on your platform. If they are unavailable, using them will raise a
NotImplementedError.

It's an error to use dir_fd or follow_symlinks when specifying path as


an open file descriptor.

statvfs(path)
Perform a statvfs system call on the given path.
path may always be specified as a string.
On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.

strerror(code, /)
Translate an error code to a message string.

symlink(src, dst, target_is_directory=False, *, dir_fd=None)


Create a symbolic link pointing to src named dst.

target_is_directory is required on Windows if the target is to be


interpreted as a directory. (On Windows, symlink requires
Windows 6.0 or greater, and raises a NotImplementedError otherwise.)
target_is_directory is ignored on non-Windows platforms.

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

sync()
Force write of everything to disk.

sysconf(name, /)
Return an integer-valued system configuration variable.

system(command)
Execute the command in a subshell.

tcgetpgrp(fd, /)
Return the process group associated with the terminal specified by fd.

tcsetpgrp(fd, pgid, /)
Set the process group associated with the terminal specified by fd.

times()
Return a collection containing process timing information.

The object returned behaves like a named tuple with these fields:
(utime, stime, cutime, cstime, elapsed_time)
All fields are floating point numbers.

truncate(path, length)
Truncate a file, specified by path, to a specific length.
On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.

ttyname(fd, /)
Return the name of the terminal device connected to 'fd'.

fd
Integer file descriptor handle.

umask(mask, /)
Set the current numeric umask and return the previous umask.

uname()
Return an object identifying the current operating system.

The object behaves like a named tuple with the following fields:
(sysname, nodename, release, version, machine)

unlink(path, *, dir_fd=None)
Remove a file (same as remove()).

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

unsetenv(name, /)
Delete an environment variable.

urandom(size, /)
Return a bytes object containing random bytes suitable for
cryptographic use.

utime(...)
Set the access and modified time of path.

path may always be specified as a string.


On some platforms, path may also be specified as an open file
descriptor.
If this functionality is unavailable, using it raises an exception.

If times is not None, it must be a tuple (atime, mtime);


atime and mtime should be expressed as float seconds since the
epoch.
If ns is specified, it must be a tuple (atime_ns, mtime_ns);
atime_ns and mtime_ns should be expressed as integer nanoseconds
since the epoch.
If times is None and ns is unspecified, utime uses the current time.
Specifying tuples for both times and ns is an error.

If dir_fd is not None, it should be a file descriptor open to a


directory,
and path should be relative; path will then be relative to that
directory.
If follow_symlinks is False, and the last element of the path is a
symbolic
link, utime will modify the symbolic link itself instead of the file
the
link points to.
It is an error to use dir_fd or follow_symlinks when specifying path
as an open file descriptor.
dir_fd and follow_symlinks may not be available on your platform.
If they are unavailable, using them will raise a
NotImplementedError.

wait()
Wait for completion of a child process.

Returns a tuple of information about the child process:


(pid, status)

wait3(options)
Wait for completion of a child process.

Returns a tuple of information about the child process:


(pid, status, rusage)

wait4(pid, options)
Wait for completion of a specific child process.

Returns a tuple of information about the child process:


(pid, status, rusage)

waitid(idtype, id, options, /)


Returns the result of waiting for a process or processes.

idtype
Must be one of be P_PID, P_PGID or P_ALL.
id
The id to wait on.
options
Constructed from the ORing of one or more of WEXITED, WSTOPPED
or WCONTINUED and additionally may be ORed with WNOHANG or
WNOWAIT.

Returns either waitid_result or None if WNOHANG is specified and there


are
no children in a waitable state.

waitpid(pid, options, /)
Wait for completion of a given child process.

Returns a tuple of information regarding the child process:


(pid, status)

The options argument is ignored on Windows.

waitstatus_to_exitcode(status)
Convert a wait status to an exit code.

On Unix:

* If WIFEXITED(status) is true, return WEXITSTATUS(status).


* If WIFSIGNALED(status) is true, return -WTERMSIG(status).
* Otherwise, raise a ValueError.

On Windows, return status shifted right by 8 bits.

On Unix, if the process is being traced or if waitpid() was called


with
WUNTRACED option, the caller must first check if WIFSTOPPED(status) is
true.
This function must not be called if WIFSTOPPED(status) is true.

walk(top, topdown=True, onerror=None, followlinks=False)


Directory tree generator.

For each directory in the directory tree rooted at top (including top
itself, but excluding '.' and '..'), yields a 3-tuple

dirpath, dirnames, filenames

dirpath is a string, the path to the directory. dirnames is a list of


the names of the subdirectories in dirpath (including symlinks to
directories,
and excluding '.' and '..').
filenames is a list of the names of the non-directory files in
dirpath.
Note that the names in the lists are just names, with no path
components.
To get a full path (which begins with top) to a file or directory in
dirpath, do [Link](dirpath, name).

If optional arg 'topdown' is true or not specified, the triple for a


directory is generated before the triples for any of its
subdirectories
(directories are generated top down). If topdown is false, the triple
for a directory is generated after the triples for all of its
subdirectories (directories are generated bottom up).

When topdown is true, the caller can modify the dirnames list in-place
(e.g., via del or slice assignment), and walk will only recurse into
the
subdirectories whose names remain in dirnames; this can be used to
prune the
search, or to impose a specific order of visiting. Modifying dirnames
when
topdown is false has no effect on the behavior of [Link](), since the
directories in dirnames have already been generated by the time
dirnames
itself is generated. No matter the value of topdown, the list of
subdirectories is retrieved before the tuples for the directory and
its
subdirectories are generated.

By default errors from the [Link]() call are ignored. If


optional arg 'onerror' is specified, it should be a function; it
will be called with one argument, an OSError instance. It can
report the error to continue with the walk, or raise the exception
to abort the walk. Note that the filename is available as the
filename attribute of the exception object.

By default, [Link] does not follow symbolic links to subdirectories


on
systems that support them. In order to get this functionality, set
the
optional argument 'followlinks' to true.

Caution: if you pass a relative pathname for top, don't change the
current working directory between resumptions of walk. walk never
changes the current directory, and assumes that the client doesn't
either.

Example:

import os
from [Link] import join, getsize
for root, dirs, files in [Link]('python/Lib/email'):
print(root, "consumes", end="")
print(sum(getsize(join(root, name)) for name in files), end="")
print("bytes in", len(files), "non-directory files")
if 'CVS' in dirs:
[Link]('CVS') # don't visit CVS directories

write(fd, data, /)
Write a bytes object to a file descriptor.

writev(fd, buffers, /)
Iterate over buffers, and write the contents of each to a file
descriptor.

Returns the total number of bytes written.


buffers must be a sequence of bytes-like objects.

DATA
CLD_CONTINUED = 6
CLD_DUMPED = 3
CLD_EXITED = 1
CLD_KILLED = 2
CLD_STOPPED = 5
CLD_TRAPPED = 4
EFD_CLOEXEC = 524288
EFD_NONBLOCK = 2048
EFD_SEMAPHORE = 1
EX_CANTCREAT = 73
EX_CONFIG = 78
EX_DATAERR = 65
EX_IOERR = 74
EX_NOHOST = 68
EX_NOINPUT = 66
EX_NOPERM = 77
EX_NOUSER = 67
EX_OK = 0
EX_OSERR = 71
EX_OSFILE = 72
EX_PROTOCOL = 76
EX_SOFTWARE = 70
EX_TEMPFAIL = 75
EX_UNAVAILABLE = 69
EX_USAGE = 64
F_LOCK = 1
F_OK = 0
F_TEST = 3
F_TLOCK = 2
F_ULOCK = 0
GRND_NONBLOCK = 1
GRND_RANDOM = 2
MFD_ALLOW_SEALING = 2
MFD_CLOEXEC = 1
MFD_HUGETLB = 4
MFD_HUGE_16GB = 2281701376
MFD_HUGE_16MB = 1610612736
MFD_HUGE_1GB = 2013265920
MFD_HUGE_1MB = 1342177280
MFD_HUGE_256MB = 1879048192
MFD_HUGE_2GB = 2080374784
MFD_HUGE_2MB = 1409286144
MFD_HUGE_32MB = 1677721600
MFD_HUGE_512KB = 1275068416
MFD_HUGE_512MB = 1946157056
MFD_HUGE_64KB = 1073741824
MFD_HUGE_8MB = 1543503872
MFD_HUGE_MASK = 63
MFD_HUGE_SHIFT = 26
NGROUPS_MAX = 65536
O_ACCMODE = 3
O_APPEND = 1024
O_ASYNC = 8192
O_CLOEXEC = 524288
O_CREAT = 64
O_DIRECT = 16384
O_DIRECTORY = 65536
O_DSYNC = 4096
O_EXCL = 128
O_FSYNC = 1052672
O_LARGEFILE = 0
O_NDELAY = 2048
O_NOATIME = 262144
O_NOCTTY = 256
O_NOFOLLOW = 131072
O_NONBLOCK = 2048
O_PATH = 2097152
O_RDONLY = 0
O_RDWR = 2
O_RSYNC = 1052672
O_SYNC = 1052672
O_TMPFILE = 4259840
O_TRUNC = 512
O_WRONLY = 1
POSIX_FADV_DONTNEED = 4
POSIX_FADV_NOREUSE = 5
POSIX_FADV_NORMAL = 0
POSIX_FADV_RANDOM = 1
POSIX_FADV_SEQUENTIAL = 2
POSIX_FADV_WILLNEED = 3
POSIX_SPAWN_CLOSE = 1
POSIX_SPAWN_DUP2 = 2
POSIX_SPAWN_OPEN = 0
PRIO_PGRP = 1
PRIO_PROCESS = 0
PRIO_USER = 2
P_ALL = 0
P_NOWAIT = 1
P_NOWAITO = 1
P_PGID = 2
P_PID = 1
P_PIDFD = 3
P_WAIT = 0
RTLD_DEEPBIND = 8
RTLD_GLOBAL = 256
RTLD_LAZY = 1
RTLD_LOCAL = 0
RTLD_NODELETE = 4096
RTLD_NOLOAD = 4
RTLD_NOW = 2
RWF_APPEND = 16
RWF_DSYNC = 2
RWF_HIPRI = 1
RWF_NOWAIT = 8
RWF_SYNC = 4
R_OK = 4
SCHED_BATCH = 3
SCHED_FIFO = 1
SCHED_IDLE = 5
SCHED_OTHER = 0
SCHED_RESET_ON_FORK = 1073741824
SCHED_RR = 2
SEEK_CUR = 1
SEEK_DATA = 3
SEEK_END = 2
SEEK_HOLE = 4
SEEK_SET = 0
SPLICE_F_MORE = 4
SPLICE_F_MOVE = 1
SPLICE_F_NONBLOCK = 2
ST_APPEND = 256
ST_MANDLOCK = 64
ST_NOATIME = 1024
ST_NODEV = 4
ST_NODIRATIME = 2048
ST_NOEXEC = 8
ST_NOSUID = 2
ST_RDONLY = 1
ST_RELATIME = 4096
ST_SYNCHRONOUS = 16
ST_WRITE = 128
TMP_MAX = 238328
WCONTINUED = 8
WEXITED = 4
WNOHANG = 1
WNOWAIT = 16777216
WSTOPPED = 2
WUNTRACED = 2
W_OK = 2
XATTR_CREATE = 1
XATTR_REPLACE = 2
XATTR_SIZE_MAX = 65536
X_OK = 1
__all__ = ['altsep', 'curdir', 'pardir', 'sep', 'pathsep', 'linesep', ...
altsep = None
confstr_names = {'CS_GNU_LIBC_VERSION': 2, 'CS_GNU_LIBPTHREAD_VERSION'...
curdir = '.'
defpath = '/bin:/usr/bin'
devnull = '/dev/null'
environ = environ({'PYTHONPATH': ':/usr/bin/entry', 'BORG_...n:/usr/lo...
environb = environ({b'PYTHONPATH': b':/usr/bin/entry', b'BO...n:/usr/l...
extsep = '.'
linesep = '\n'
name = 'posix'
pardir = '..'
pathconf_names = {'PC_ALLOC_SIZE_MIN': 18, 'PC_ASYNC_IO': 10, 'PC_CHOW...
pathsep = ':'
sep = '/'
supports_bytes_environ = True
sysconf_names = {'SC_2_CHAR_TERM': 95, 'SC_2_C_BIND': 47, 'SC_2_C_DEV'...

FILE
/usr/local/lib/python3.10/[Link]

Python Library Documentation: built-in module itertools

NAME
itertools - Functional tools for creating and using iterators.

DESCRIPTION
Infinite iterators:
count(start=0, step=1) --> start, start+step, start+2*step, ...
cycle(p) --> p0, p1, ... plast, p0, p1, ...
repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times

Iterators terminating on the shortest input sequence:


accumulate(p[, func]) --> p0, p0+p1, p0+p1+p2
chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ...
chain.from_iterable([p, q, ...]) --> p0, p1, ... plast, q0, q1, ...
compress(data, selectors) --> (d[0] if s[0]), (d[1] if s[1]), ...
dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails
groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of
keyfunc(v)
filterfalse(pred, seq) --> elements of seq where pred(elem) is False
islice(seq, [start,] stop [, step]) --> elements from
seq[start:stop:step]
pairwise(s) --> (s[0],s[1]), (s[1],s[2]), (s[2], s[3]), ...
starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...
tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n
takewhile(pred, seq) --> seq[0], seq[1], until pred fails
zip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...

Combinatoric generators:
product(p, q, ... [repeat=1]) --> cartesian product
permutations(p[, r])
combinations(p, r)
combinations_with_replacement(p, r)

CLASSES
[Link]
accumulate
chain
combinations
combinations_with_replacement
compress
count
cycle
dropwhile
filterfalse
groupby
islice
pairwise
permutations
product
repeat
starmap
takewhile
zip_longest

class accumulate([Link])
| accumulate(iterable, func=None, *, initial=None)
|
| Return series of accumulated sums (or other binary function results).
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class chain([Link])
| chain(*iterables) --> chain object
|
| Return a chain object whose .__next__() method returns elements from
the
| first iterable until it is exhausted, then elements from the next
| iterable, until all of the iterables are exhausted.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...) from [Link]
| See PEP 585
|
| from_iterable(iterable, /) from [Link]
| Alternative chain() constructor taking a single iterable argument
that evaluates lazily.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class combinations([Link])
| combinations(iterable, r)
|
| Return successive r-length combinations of elements in the iterable.
|
| combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class combinations_with_replacement([Link])
| combinations_with_replacement(iterable, r)
|
| Return successive r-length combinations of elements in the iterable
allowing individual elements to have successive repeats.
|
| combinations_with_replacement('ABC', 2) --> ('A','A'), ('A','B'),
('A','C'), ('B','B'), ('B','C'), ('C','C')
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class compress([Link])
| compress(data, selectors)
|
| Return data elements corresponding to true selector elements.
|
| Forms a shorter iterator from selected data elements using the
selectors to
| choose the data elements.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class count([Link])
| count(start=0, step=1)
|
| Return a count object whose .__next__() method returns consecutive
values.
|
| Equivalent to:
| def count(firstval=0, step=1):
| x = firstval
| while 1:
| yield x
| x += step
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class cycle([Link])
| cycle(iterable, /)
|
| Return elements from the iterable until it is exhausted. Then repeat
the sequence indefinitely.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class dropwhile([Link])
| dropwhile(predicate, iterable, /)
|
| Drop items from the iterable while predicate(item) is true.
|
| Afterwards, return every element until the iterable is exhausted.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class filterfalse([Link])
| filterfalse(function, iterable, /)
|
| Return those items of iterable for which function(item) is false.
|
| If function is None, return the items that are false.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class groupby([Link])
| groupby(iterable, key=None)
|
| make an iterator that returns consecutive keys and groups from the
iterable
|
| iterable
| Elements to divide into groups according to the key function.
| key
| A function for computing the group category for each element.
| If the key function is not specified or is None, the element itself
| is used for grouping.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class islice([Link])
| islice(iterable, stop) --> islice object
| islice(iterable, start, stop[, step]) --> islice object
|
| Return an iterator whose next() method returns selected values from an
| iterable. If start is specified, will skip all preceding elements;
| otherwise, start defaults to zero. Step defaults to one. If
| specified as another value, step determines how many values are
| skipped between successive calls. Works like a slice() on a list
| but returns an iterator.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class pairwise([Link])
| pairwise(iterable, /)
|
| Return an iterator of overlapping pairs taken from the input iterator.
|
| s -> (s0,s1), (s1,s2), (s2, s3), ...
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class permutations([Link])
| permutations(iterable, r=None)
|
| Return successive r-length permutations of elements in the iterable.
|
| permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class product([Link])
| product(*iterables, repeat=1) --> product object
|
| Cartesian product of input iterables. Equivalent to nested for-loops.
|
| For example, product(A, B) returns the same as: ((x,y) for x in A for
y in B).
| The leftmost iterators are in the outermost for-loop, so the output
tuples
| cycle in a manner similar to an odometer (with the rightmost element
changing
| on every iteration).
|
| To compute the product of an iterable with itself, specify the number
| of repetitions with the optional repeat keyword argument. For example,
| product(A, repeat=4) means the same as product(A, A, A, A).
|
| product('ab', range(3)) --> ('a',0) ('a',1) ('a',2) ('b',0) ('b',1)
('b',2)
| product((0,1), (0,1), (0,1)) --> (0,0,0) (0,0,1) (0,1,0) (0,1,1)
(1,0,0) ...
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class repeat([Link])
| repeat(object [,times]) -> create an iterator which returns the object
| for the specified number of times. If not specified, returns the
object
| endlessly.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __length_hint__(...)
| Private method returning an estimate of len(list(it)).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class starmap([Link])
| starmap(function, iterable, /)
|
| Return an iterator whose values are returned from the function
evaluated with an argument tuple taken from the given sequence.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class takewhile([Link])
| takewhile(predicate, iterable, /)
|
| Return successive entries from an iterable as long as the predicate
evaluates to true for each entry.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class zip_longest([Link])
| zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) --> zip_longest
object
|
| Return a zip_longest object whose .__next__() method returns a tuple
where
| the i-th element comes from the i-th iterable argument.
The .__next__()
| method continues until the longest iterable in the argument sequence
| is exhausted and then it raises StopIteration. When the shorter
iterables
| are exhausted, the fillvalue is substituted in their place. The
fillvalue
| defaults to None or can be specified by a keyword argument.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

FUNCTIONS
tee(iterable, n=2, /)
Returns a tuple of n independent iterators.

FILE
(built-in)

Python Library Documentation: package collections

NAME
collections

MODULE REFERENCE
[Link]

The following documentation is automatically generated from the Python


source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.

DESCRIPTION
This module implements specialized container datatypes providing
alternatives to Python's general purpose built-in containers, dict,
list, set, and tuple.

* namedtuple factory function for creating tuple subclasses with named


fields
* deque list-like container with fast appends and pops on either
end
* ChainMap dict-like class for creating a single view of multiple
mappings
* Counter dict subclass for counting hashable objects
* OrderedDict dict subclass that remembers the order entries were added
* defaultdict dict subclass that calls a factory function to supply
missing values
* UserDict wrapper around dictionary objects for easier dict
subclassing
* UserList wrapper around list objects for easier list subclassing
* UserString wrapper around string objects for easier string subclassing

PACKAGE CONTENTS
abc

SUBMODULES
_collections_abc

CLASSES
[Link]([Link])
Counter
OrderedDict
defaultdict
[Link]
deque
[Link]([Link])
ChainMap
UserDict
[Link]([Link])
UserList
[Link]([Link],
[Link])
UserString

class ChainMap([Link])
| ChainMap(*maps)
|
| A ChainMap groups multiple dicts (or other mappings) together
| to create a single, updateable view.
|
| The underlying mappings are stored in a list. That list is public and
can
| be accessed or updated using the *maps* attribute. There is no other
| state.
|
| Lookups search the underlying mappings successively until a key is
found.
| In contrast, writes, updates, and deletions only operate on the first
| mapping.
|
| Method resolution order:
| ChainMap
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
|
| Methods defined here:
|
| __bool__(self)
|
| __contains__(self, key)
|
| __copy__ = copy(self)
|
| __delitem__(self, key)
|
| __getitem__(self, key)
|
| __init__(self, *maps)
| Initialize a ChainMap by setting *maps* to the given mappings.
| If no mappings are provided, a single empty dictionary is used.
|
| __ior__(self, other)
|
| __iter__(self)
|
| __len__(self)
|
| __missing__(self, key)
|
| __or__(self, other)
| Return self|value.
|
| __repr__(self)
| Return repr(self).
|
| __ror__(self, other)
| Return value|self.
|
| __setitem__(self, key, value)
|
| clear(self)
| Clear maps[0], leaving maps[1:] intact.
|
| copy(self)
| New ChainMap or subclass with a new copy of maps[0] and refs to
maps[1:]
|
| get(self, key, default=None)
| [Link](k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| new_child(self, m=None, **kwargs)
| New ChainMap with a new map followed by all previous maps.
| If no map is provided, an empty dict is used.
| Keyword arguments update the map or new empty dict.
|
| pop(self, key, *args)
| Remove *key* from maps[0] and return its value. Raise KeyError if
*key* not in maps[0].
|
| popitem(self)
| Remove and return an item pair from maps[0]. Raise KeyError is
maps[0] is empty.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, *args) from [Link]
| Create a ChainMap with a single dict created from the iterable.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| parents
| New ChainMap from maps[1:].
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| setdefault(self, key, default=None)
| [Link](k[,d]) -> [Link](k,d), also set D[k]=d if k not in D
|
| update(self, other=(), /, **kwds)
| [Link]([E, ]**F) -> None. Update D from mapping/iterable E and
F.
| If E present and has a .keys() method, does: for k in E: D[k]
= E[k]
| If E present and lacks .keys() method, does: for (k, v) in E:
D[k] = v
| In either case, this is followed by: for k, v in [Link](): D[k] =
v
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __eq__(self, other)
| Return self==value.
|
| items(self)
| [Link]() -> a set-like object providing a view on D's items
|
| keys(self)
| [Link]() -> a set-like object providing a view on D's keys
|
| values(self)
| [Link]() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from [Link]:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __subclasshook__(C) from [Link]
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by [Link].__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__ = GenericAlias(...) from [Link]
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is
(int,).

class Counter([Link])
| Counter(iterable=None, /, **kwds)
|
| Dict subclass for counting hashable items. Sometimes called a bag
| or multiset. Elements are stored as dictionary keys and their counts
| are stored as dictionary values.
|
| >>> c = Counter('abcdeabcdabcaba') # count elements from a string
|
| >>> c.most_common(3) # three most common elements
| [('a', 5), ('b', 4), ('c', 3)]
| >>> sorted(c) # list all unique elements
| ['a', 'b', 'c', 'd', 'e']
| >>> ''.join(sorted([Link]())) # list elements with repetitions
| 'aaaaabbbbcccdde'
| >>> sum([Link]()) # total of all counts
| 15
|
| >>> c['a'] # count of letter 'a'
| 5
| >>> for elem in 'shazam': # update counts from an iterable
| ... c[elem] += 1 # by adding 1 to each element's
count
| >>> c['a'] # now there are seven 'a'
| 7
| >>> del c['b'] # remove all 'b'
| >>> c['b'] # now there are zero 'b'
| 0
|
| >>> d = Counter('simsalabim') # make another counter
| >>> [Link](d) # add in the second counter
| >>> c['a'] # now there are nine 'a'
| 9
|
| >>> [Link]() # empty the counter
| >>> c
| Counter()
|
| Note: If a count is set to zero or reduced to zero, it will remain
| in the counter until the entry is deleted or the counter is cleared:
|
| >>> c = Counter('aaabbc')
| >>> c['b'] -= 2 # reduce the count of 'b' by two
| >>> c.most_common() # 'b' is still in, but its count
is zero
| [('a', 3), ('c', 1), ('b', 0)]
|
| Method resolution order:
| Counter
| [Link]
| [Link]
|
| Methods defined here:
|
| __add__(self, other)
| Add counts from two counters.
|
| >>> Counter('abbb') + Counter('bcc')
| Counter({'b': 4, 'c': 2, 'a': 1})
|
| __and__(self, other)
| Intersection is the minimum of corresponding counts.
|
| >>> Counter('abbb') & Counter('bcc')
| Counter({'b': 1})
|
| __delitem__(self, elem)
| Like dict.__delitem__() but does not raise KeyError for missing
values.
|
| __eq__(self, other)
| True if all counts agree. Missing counts are treated as zero.
|
| __ge__(self, other)
| True if all counts in self are a superset of those in other.
|
| __gt__(self, other)
| True if all counts in self are a proper superset of those in
other.
|
| __iadd__(self, other)
| Inplace add from another counter, keeping only positive counts.
|
| >>> c = Counter('abbb')
| >>> c += Counter('bcc')
| >>> c
| Counter({'b': 4, 'c': 2, 'a': 1})
|
| __iand__(self, other)
| Inplace intersection is the minimum of corresponding counts.
|
| >>> c = Counter('abbb')
| >>> c &= Counter('bcc')
| >>> c
| Counter({'b': 1})
|
| __init__(self, iterable=None, /, **kwds)
| Create a new, empty Counter object. And if given, count elements
| from an input iterable. Or, initialize the count from another
mapping
| of elements to their counts.
|
| >>> c = Counter() # a new, empty counter
| >>> c = Counter('gallahad') # a new counter from
an iterable
| >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a
mapping
| >>> c = Counter(a=4, b=2) # a new counter from
keyword args
|
| __ior__(self, other)
| Inplace union is the maximum of value from either counter.
|
| >>> c = Counter('abbb')
| >>> c |= Counter('bcc')
| >>> c
| Counter({'b': 3, 'c': 2, 'a': 1})
|
| __isub__(self, other)
| Inplace subtract counter, but keep only results with positive
counts.
|
| >>> c = Counter('abbbc')
| >>> c -= Counter('bccd')
| >>> c
| Counter({'b': 2, 'a': 1})
|
| __le__(self, other)
| True if all counts in self are a subset of those in other.
|
| __lt__(self, other)
| True if all counts in self are a proper subset of those in other.
|
| __missing__(self, key)
| The count of elements not in the Counter is zero.
|
| __ne__(self, other)
| True if any counts disagree. Missing counts are treated as zero.
|
| __neg__(self)
| Subtracts from an empty counter. Strips positive and zero counts,
| and flips the sign on negative counts.
|
| __or__(self, other)
| Union is the maximum of value in either of the input counters.
|
| >>> Counter('abbb') | Counter('bcc')
| Counter({'b': 3, 'c': 2, 'a': 1})
|
| __pos__(self)
| Adds an empty counter, effectively stripping negative and zero
counts
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| __sub__(self, other)
| Subtract count, but keep only results with positive counts.
|
| >>> Counter('abbbc') - Counter('bccd')
| Counter({'b': 2, 'a': 1})
|
| copy(self)
| Return a shallow copy.
|
| elements(self)
| Iterator over elements repeating each as many times as its count.
|
| >>> c = Counter('ABCABC')
| >>> sorted([Link]())
| ['A', 'A', 'B', 'B', 'C', 'C']
|
| # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1
| >>> prime_factors = Counter({2: 2, 3: 3, 17: 1})
| >>> product = 1
| >>> for factor in prime_factors.elements(): # loop over
factors
| ... product *= factor # and multiply
them
| >>> product
| 1836
|
| Note, if an element's count has been set to zero or is a negative
| number, elements() will ignore it.
|
| most_common(self, n=None)
| List the n most common elements and their counts from the most
| common to the least. If n is None, then list all element counts.
|
| >>> Counter('abracadabra').most_common(3)
| [('a', 5), ('b', 2), ('r', 2)]
|
| subtract(self, iterable=None, /, **kwds)
| Like [Link]() but subtracts counts instead of replacing them.
| Counts can be reduced below zero. Both the inputs and outputs are
| allowed to contain zero and negative counts.
|
| Source can be an iterable, a dictionary, or another Counter
instance.
|
| >>> c = Counter('which')
| >>> [Link]('witch') # subtract elements from
another iterable
| >>> [Link](Counter('watch')) # subtract elements from
another counter
| >>> c['h'] # 2 in which, minus 1 in
witch, minus 1 in watch
| 0
| >>> c['w'] # 1 in which, minus 1 in
witch, minus 1 in watch
| -1
|
| total(self)
| Sum of the counts
|
| update(self, iterable=None, /, **kwds)
| Like [Link]() but add counts instead of replacing them.
|
| Source can be an iterable, a dictionary, or another Counter
instance.
|
| >>> c = Counter('which')
| >>> [Link]('witch') # add elements from another
iterable
| >>> d = Counter('watch')
| >>> [Link](d) # add elements from another
counter
| >>> c['h'] # four 'h' in which, witch, and
watch
| 4
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, v=None) from [Link]
| Create a new dictionary with keys from iterable and values set to
value.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(...)
| x.__getitem__(y) <==> x[y]
|
| __iter__(self, /)
| Implement iter(self).
|
| __len__(self, /)
| Return len(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| [Link]() -> None. Remove all items from D.
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else
default.
|
| items(...)
| [Link]() -> a set-like object providing a view on D's items
|
| keys(...)
| [Link]() -> a set-like object providing a view on D's keys
|
| pop(...)
| [Link](k[,d]) -> v, remove specified key and return the
corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the
dictionary.
|
| Return the value for key if key is in the dictionary, else
default.
|
| values(...)
| [Link]() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585
|
| ----------------------------------------------------------------------
| Static methods inherited from [Link]:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class OrderedDict([Link])
| Dictionary that remembers insertion order
|
| Method resolution order:
| OrderedDict
| [Link]
| [Link]
|
| Methods defined here:
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __reduce__(...)
| Return state information for pickling
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(...)
| od.__reversed__() <==> reversed(od)
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| [Link]() -> None. Remove all items from od.
|
| copy(...)
| [Link]() -> a shallow copy of od
|
| items(...)
| [Link]() -> a set-like object providing a view on D's items
|
| keys(...)
| [Link]() -> a set-like object providing a view on D's keys
|
| move_to_end(self, /, key, last=True)
| Move an existing element to the end (or beginning if last is
false).
|
| Raise KeyError if the element does not exist.
|
| pop(...)
| [Link](key[,default]) -> v, remove specified key and return the
corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /, last=True)
| Remove and return a (key, value) pair from the dictionary.
|
| Pairs are returned in LIFO order if last is true or FIFO order if
false.
|
| setdefault(self, /, key, default=None)
| Insert key with a value of default if key is not in the
dictionary.
|
| Return the value for key if key is in the dictionary, else
default.
|
| update(...)
| [Link]([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E:
D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v
in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| [Link]() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, value=None) from [Link]
| Create a new ordered dictionary with keys from iterable and values
set to value.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(...)
| x.__getitem__(y) <==> x[y]
|
| __len__(self, /)
| Return len(self).
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else
default.
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__(...) from [Link]
| See PEP 585
|
| ----------------------------------------------------------------------
| Static methods inherited from [Link]:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.

class UserDict([Link])
| UserDict(dict=None, /, **kwargs)
|
| Method resolution order:
| UserDict
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
|
| Methods defined here:
|
| __contains__(self, key)
| # Modify __contains__ to work correctly when __missing__ is
present
|
| __copy__(self)
|
| __delitem__(self, key)
|
| __getitem__(self, key)
|
| __init__(self, dict=None, /, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, other)
|
| __iter__(self)
|
| __len__(self)
|
| __or__(self, other)
| Return self|value.
|
| __repr__(self)
| Return repr(self).
|
| __ror__(self, other)
| Return value|self.
|
| __setitem__(self, key, item)
|
| copy(self)
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, value=None) from [Link]
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| clear(self)
| [Link]() -> None. Remove all items from D.
|
| pop(self, key, default=<object object at 0x7fc5385603f0>)
| [Link](k[,d]) -> v, remove specified key and return the
corresponding value.
| If key is not found, d is returned if given, otherwise KeyError is
raised.
|
| popitem(self)
| [Link]() -> (k, v), remove and return some (key, value) pair
| as a 2-tuple; but raise KeyError if D is empty.
|
| setdefault(self, key, default=None)
| [Link](k[,d]) -> [Link](k,d), also set D[k]=d if k not in D
|
| update(self, other=(), /, **kwds)
| [Link]([E, ]**F) -> None. Update D from mapping/iterable E and
F.
| If E present and has a .keys() method, does: for k in E: D[k]
= E[k]
| If E present and lacks .keys() method, does: for (k, v) in E:
D[k] = v
| In either case, this is followed by: for k, v in [Link](): D[k] =
v
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __eq__(self, other)
| Return self==value.
|
| get(self, key, default=None)
| [Link](k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| items(self)
| [Link]() -> a set-like object providing a view on D's items
|
| keys(self)
| [Link]() -> a set-like object providing a view on D's keys
|
| values(self)
| [Link]() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from [Link]:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __subclasshook__(C) from [Link]
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by [Link].__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__ = GenericAlias(...) from [Link]
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is
(int,).

class UserList([Link])
| UserList(initlist=None)
|
| A more or less complete user-defined wrapper around list objects.
|
| Method resolution order:
| UserList
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
|
| Methods defined here:
|
| __add__(self, other)
|
| __contains__(self, item)
|
| __copy__(self)
|
| __delitem__(self, i)
|
| __eq__(self, other)
| Return self==value.
|
| __ge__(self, other)
| Return self>=value.
|
| __getitem__(self, i)
|
| __gt__(self, other)
| Return self>value.
|
| __iadd__(self, other)
|
| __imul__(self, n)
|
| __init__(self, initlist=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| __le__(self, other)
| Return self<=value.
|
| __len__(self)
|
| __lt__(self, other)
| Return self<value.
|
| __mul__(self, n)
|
| __radd__(self, other)
|
| __repr__(self)
| Return repr(self).
|
| __rmul__ = __mul__(self, n)
|
| __setitem__(self, i, item)
|
| append(self, item)
| [Link](value) -- append value to the end of the sequence
|
| clear(self)
| [Link]() -> None -- remove all items from S
|
| copy(self)
|
| count(self, item)
| [Link](value) -> integer -- return number of occurrences of value
|
| extend(self, other)
| [Link](iterable) -- extend sequence by appending elements from
the iterable
|
| index(self, item, *args)
| [Link](value, [start, [stop]]) -> integer -- return first index
of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| insert(self, i, item)
| [Link](index, value) -- insert value before index
|
| pop(self, i=-1)
| [Link]([index]) -> item -- remove and return item at index (default
last).
| Raise IndexError if list is empty or index is out of range.
|
| remove(self, item)
| [Link](value) -- remove first occurrence of value.
| Raise ValueError if the value is not present.
|
| reverse(self)
| [Link]() -- reverse *IN PLACE*
|
| sort(self, /, *args, **kwds)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __iter__(self)
|
| __reversed__(self)
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __subclasshook__(C) from [Link]
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by [Link].__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__ = GenericAlias(...) from [Link]
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is
(int,).

class UserString([Link])
| UserString(seq)
|
| Method resolution order:
| UserString
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
| [Link]
|
| Methods defined here:
|
| __add__(self, other)
|
| __complex__(self)
|
| __contains__(self, char)
|
| __eq__(self, string)
| Return self==value.
|
| __float__(self)
|
| __ge__(self, string)
| Return self>=value.
|
| __getitem__(self, index)
|
| __getnewargs__(self)
|
| __gt__(self, string)
| Return self>value.
|
| __hash__(self)
| Return hash(self).
|
| __init__(self, seq)
| Initialize self. See help(type(self)) for accurate signature.
|
| __int__(self)
|
| __le__(self, string)
| Return self<=value.
|
| __len__(self)
|
| __lt__(self, string)
| Return self<value.
|
| __mod__(self, args)
|
| __mul__(self, n)
|
| __radd__(self, other)
|
| __repr__(self)
| Return repr(self).
|
| __rmod__(self, template)
|
| __rmul__ = __mul__(self, n)
|
| __str__(self)
| Return str(self).
|
| capitalize(self)
| # the following methods are defined in alphabetical order:
|
| casefold(self)
|
| center(self, width, *args)
|
| count(self, sub, start=0, end=9223372036854775807)
| [Link](value) -> integer -- return number of occurrences of value
|
| encode(self, encoding='utf-8', errors='strict')
|
| endswith(self, suffix, start=0, end=9223372036854775807)
|
| expandtabs(self, tabsize=8)
|
| find(self, sub, start=0, end=9223372036854775807)
|
| format(self, /, *args, **kwds)
|
| format_map(self, mapping)
|
| index(self, sub, start=0, end=9223372036854775807)
| [Link](value, [start, [stop]]) -> integer -- return first index
of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| isalnum(self)
|
| isalpha(self)
|
| isascii(self)
|
| isdecimal(self)
|
| isdigit(self)
|
| isidentifier(self)
|
| islower(self)
|
| isnumeric(self)
|
| isprintable(self)
|
| isspace(self)
|
| istitle(self)
|
| isupper(self)
|
| join(self, seq)
|
| ljust(self, width, *args)
|
| lower(self)
|
| lstrip(self, chars=None)
|
| partition(self, sep)
|
| removeprefix(self, prefix, /)
|
| removesuffix(self, suffix, /)
|
| replace(self, old, new, maxsplit=-1)
|
| rfind(self, sub, start=0, end=9223372036854775807)
|
| rindex(self, sub, start=0, end=9223372036854775807)
|
| rjust(self, width, *args)
|
| rpartition(self, sep)
|
| rsplit(self, sep=None, maxsplit=-1)
|
| rstrip(self, chars=None)
|
| split(self, sep=None, maxsplit=-1)
|
| splitlines(self, keepends=False)
|
| startswith(self, prefix, start=0, end=9223372036854775807)
|
| strip(self, chars=None)
|
| swapcase(self)
|
| title(self)
|
| translate(self, *args)
|
| upper(self)
|
| zfill(self, width)
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| maketrans(...)
| Return a translation table usable for [Link]().
|
| If there is only one argument, it must be a dictionary mapping
Unicode
| ordinals (integers) or characters to Unicode ordinals, strings or
None.
| Character keys will be then converted to ordinals.
| If there are two arguments, they must be strings of equal length,
and
| in the resulting dictionary, each character in x will be mapped to
the
| character at the same position in y. If there is a third argument,
it
| must be a string, whose characters will be mapped to None in the
result.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __iter__(self)
|
| __reversed__(self)
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __subclasshook__(C) from [Link]
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by [Link].__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| __class_getitem__ = GenericAlias(...) from [Link]
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is
(int,).

class defaultdict([Link])
| defaultdict(default_factory=None, /, [...]) --> dict with default
factory
|
| The default factory is called without arguments to produce
| a new value when a key is not present, in __getitem__ only.
| A defaultdict compares equal to a dict with the same items.
| All remaining arguments are treated the same as if they were
| passed to the dict constructor, including keyword arguments.
|
| Method resolution order:
| defaultdict
| [Link]
| [Link]
|
| Methods defined here:
|
| __copy__(...)
| [Link]() -> a shallow copy of D.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __missing__(...)
| __missing__(key) # Called by __getitem__ for missing key; pseudo-
code:
| if self.default_factory is None: raise KeyError((key,))
| self[key] = value = self.default_factory()
| return value
|
| __or__(self, value, /)
| Return self|value.
|
| __reduce__(...)
| Return state information for pickling.
|
| __repr__(self, /)
| Return repr(self).
|
| __ror__(self, value, /)
| Return value|self.
|
| copy(...)
| [Link]() -> a shallow copy of D.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...) from [Link]
| See PEP 585
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| default_factory
| Factory for default value called by __missing__().
|
| ----------------------------------------------------------------------
| Methods inherited from [Link]:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getitem__(...)
| x.__getitem__(y) <==> x[y]
|
| __gt__(self, value, /)
| Return self>value.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| [Link]() -> None. Remove all items from D.
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else
default.
|
| items(...)
| [Link]() -> a set-like object providing a view on D's items
|
| keys(...)
| [Link]() -> a set-like object providing a view on D's keys
|
| pop(...)
| [Link](k[,d]) -> v, remove specified key and return the
corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the
dictionary.
|
| Return the value for key if key is in the dictionary, else
default.
|
| update(...)
| [Link]([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E:
D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v
in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| [Link]() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from [Link]:
|
| fromkeys(iterable, value=None, /) from [Link]
| Create a new dictionary with keys from iterable and values set to
value.
|
| ----------------------------------------------------------------------
| Static methods inherited from [Link]:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from [Link]:
|
| __hash__ = None

class deque([Link])
| deque([iterable[, maxlen]]) --> deque object
|
| A list-like sequence optimized for data accesses near its endpoints.
|
| Methods defined here:
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| True if self else False
|
| __contains__(self, key, /)
| Return key in self.
|
| __copy__(...)
| Return a shallow copy of a deque.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __iadd__(self, value, /)
| Implement self+=value.
|
| __imul__(self, value, /)
| Implement self*=value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __reduce__(...)
| Return state information for pickling.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(...)
| D.__reversed__() -- return a reverse iterator over the deque
|
| __rmul__(self, value, /)
| Return value*self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -- size of D in memory, in bytes
|
| append(...)
| Add an element to the right side of the deque.
|
| appendleft(...)
| Add an element to the left side of the deque.
|
| clear(...)
| Remove all elements from the deque.
|
| copy(...)
| Return a shallow copy of a deque.
|
| count(...)
| [Link](value) -> integer -- return number of occurrences of value
|
| extend(...)
| Extend the right side of the deque with elements from the iterable
|
| extendleft(...)
| Extend the left side of the deque with elements from the iterable
|
| index(...)
| [Link](value, [start, [stop]]) -> integer -- return first index
of value.
| Raises ValueError if the value is not present.
|
| insert(...)
| [Link](index, object) -- insert object before index
|
| pop(...)
| Remove and return the rightmost element.
|
| popleft(...)
| Remove and return the leftmost element.
|
| remove(...)
| [Link](value) -- remove first occurrence of value.
|
| reverse(...)
| [Link]() -- reverse *IN PLACE*
|
| rotate(...)
| Rotate the deque n steps to the right (default n=1). If n is
negative, rotates left.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...) from [Link]
| See PEP 585
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from [Link]
| Create and return a new object. See help(type) for accurate
signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| maxlen
| maximum size of a deque or None if unbounded
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None

FUNCTIONS
namedtuple(typename, field_names, *, rename=False, defaults=None,
module=None)
Returns a new subclass of tuple with named fields.

>>> Point = namedtuple('Point', ['x', 'y'])


>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional args
or keywords
>>> p[0] + p[1] # indexable like a plain tuple
33
>>> x, y = p # unpack like a regular tuple
>>> x, y
(11, 22)
>>> p.x + p.y # fields also accessible by name
33
>>> d = p._asdict() # convert to a dictionary
>>> d['x']
11
>>> Point(**d) # convert from a dictionary
Point(x=11, y=22)
>>> p._replace(x=100) # _replace() is like [Link]()
but targets named fields
Point(x=100, y=22)

DATA
__all__ = ['ChainMap', 'Counter', 'OrderedDict', 'UserDict', 'UserList...

FILE
/usr/local/lib/python3.10/collections/__init__.py

You might also like