doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
reversed(seq) Return a reverse iterator. seq must be an object which has a __reversed__() method or supports the sequence protocol (the __len__() method and the __getitem__() method with integer arguments starting at 0).
python.library.functions#reversed
rlcompleter — Completion function for GNU readline Source code: Lib/rlcompleter.py The rlcompleter module defines a completion function suitable for the readline module by completing valid Python identifiers and keywords. When this module is imported on a Unix platform with the readline module available, an instance of...
python.library.rlcompleter
Completer.complete(text, state) Return the stateth completion for text. If called for text that doesn’t include a period character ('.'), it will complete from names currently defined in __main__, builtins and keywords (as defined by the keyword module). If called for a dotted name, it will try to evaluate anything w...
python.library.rlcompleter#rlcompleter.Completer.complete
round(number[, ndigits]) Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input. For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equal...
python.library.functions#round
runpy — Locating and executing Python modules Source code: Lib/runpy.py The runpy module is used to locate and run Python modules without importing them first. Its main use is to implement the -m command line switch that allows scripts to be located using the Python module namespace rather than the filesystem. Note tha...
python.library.runpy
runpy.run_module(mod_name, init_globals=None, run_name=None, alter_sys=False) Execute the code of the specified module and return the resulting module globals dictionary. The module’s code is first located using the standard import mechanism (refer to PEP 302 for details) and then executed in a fresh module namespace...
python.library.runpy#runpy.run_module
runpy.run_path(file_path, init_globals=None, run_name=None) Execute the code at the named filesystem location and return the resulting module globals dictionary. As with a script name supplied to the CPython command line, the supplied path may refer to a Python source file, a compiled bytecode file or a valid sys.pat...
python.library.runpy#runpy.run_path
exception RuntimeError Raised when an error is detected that doesn’t fall in any of the other categories. The associated value is a string indicating what precisely went wrong.
python.library.exceptions#RuntimeError
exception RuntimeWarning Base class for warnings about dubious runtime behavior.
python.library.exceptions#RuntimeWarning
sched — Event scheduler Source code: Lib/sched.py The sched module defines a class which implements a general purpose event scheduler: class sched.scheduler(timefunc=time.monotonic, delayfunc=time.sleep) The scheduler class defines a generic interface to scheduling events. It needs two functions to actually deal wi...
python.library.sched
class sched.scheduler(timefunc=time.monotonic, delayfunc=time.sleep) The scheduler class defines a generic interface to scheduling events. It needs two functions to actually deal with the “outside world” — timefunc should be callable without arguments, and return a number (the “time”, in any units whatsoever). The de...
python.library.sched#sched.scheduler
scheduler.cancel(event) Remove the event from the queue. If event is not an event currently in the queue, this method will raise a ValueError.
python.library.sched#sched.scheduler.cancel
scheduler.empty() Return True if the event queue is empty.
python.library.sched#sched.scheduler.empty
scheduler.enter(delay, priority, action, argument=(), kwargs={}) Schedule an event for delay more time units. Other than the relative time, the other arguments, the effect and the return value are the same as those for enterabs(). Changed in version 3.3: argument parameter is optional. Changed in version 3.3: kwar...
python.library.sched#sched.scheduler.enter
scheduler.enterabs(time, priority, action, argument=(), kwargs={}) Schedule a new event. The time argument should be a numeric type compatible with the return value of the timefunc function passed to the constructor. Events scheduled for the same time will be executed in the order of their priority. A lower number re...
python.library.sched#sched.scheduler.enterabs
scheduler.queue Read-only attribute returning a list of upcoming events in the order they will be run. Each event is shown as a named tuple with the following fields: time, priority, action, argument, kwargs.
python.library.sched#sched.scheduler.queue
scheduler.run(blocking=True) Run all scheduled events. This method will wait (using the delayfunc() function passed to the constructor) for the next event, then execute it and so on until there are no more scheduled events. If blocking is false executes the scheduled events due to expire soonest (if any) and then ret...
python.library.sched#sched.scheduler.run
secrets — Generate secure random numbers for managing secrets New in version 3.6. Source code: Lib/secrets.py The secrets module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets. In particular, sec...
python.library.secrets
secrets.choice(sequence) Return a randomly-chosen element from a non-empty sequence.
python.library.secrets#secrets.choice
secrets.compare_digest(a, b) Return True if strings a and b are equal, otherwise False, in such a way as to reduce the risk of timing attacks. See hmac.compare_digest() for additional details.
python.library.secrets#secrets.compare_digest
secrets.randbelow(n) Return a random int in the range [0, n).
python.library.secrets#secrets.randbelow
secrets.randbits(k) Return an int with k random bits.
python.library.secrets#secrets.randbits
class secrets.SystemRandom A class for generating random numbers using the highest-quality sources provided by the operating system. See random.SystemRandom for additional details.
python.library.secrets#secrets.SystemRandom
secrets.token_bytes([nbytes=None]) Return a random byte string containing nbytes number of bytes. If nbytes is None or not supplied, a reasonable default is used. >>> token_bytes(16) b'\xebr\x17D*t\xae\xd4\xe3S\xb6\xe2\xebP1\x8b'
python.library.secrets#secrets.token_bytes
secrets.token_hex([nbytes=None]) Return a random text string, in hexadecimal. The string has nbytes random bytes, each byte converted to two hex digits. If nbytes is None or not supplied, a reasonable default is used. >>> token_hex(16) 'f9bf78b9a18ce6d46a0cd2b0b86df9da'
python.library.secrets#secrets.token_hex
secrets.token_urlsafe([nbytes=None]) Return a random URL-safe text string, containing nbytes random bytes. The text is Base64 encoded, so on average each byte results in approximately 1.3 characters. If nbytes is None or not supplied, a reasonable default is used. >>> token_urlsafe(16) 'Drmhze6EPcv0fN_81Bj-nA'
python.library.secrets#secrets.token_urlsafe
select — Waiting for I/O completion This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ and kqueue() available on most BSD. Note that on Windows, it only works for sockets; on other operatin...
python.library.select
select.devpoll() (Only supported on Solaris and derivatives.) Returns a /dev/poll polling object; see section /dev/poll Polling Objects below for the methods supported by devpoll objects. devpoll() objects are linked to the number of file descriptors allowed at the time of instantiation. If your program reduces this ...
python.library.select#select.devpoll
devpoll.close() Close the file descriptor of the polling object. New in version 3.4.
python.library.select#select.devpoll.close
devpoll.closed True if the polling object is closed. New in version 3.4.
python.library.select#select.devpoll.closed
devpoll.fileno() Return the file descriptor number of the polling object. New in version 3.4.
python.library.select#select.devpoll.fileno
devpoll.modify(fd[, eventmask]) This method does an unregister() followed by a register(). It is (a bit) more efficient that doing the same explicitly.
python.library.select#select.devpoll.modify
devpoll.poll([timeout]) Polls the set of registered file descriptors, and returns a possibly-empty list containing (fd, event) 2-tuples for the descriptors that have events or errors to report. fd is the file descriptor, and event is a bitmask with bits set for the reported events for that descriptor — POLLIN for wai...
python.library.select#select.devpoll.poll
devpoll.register(fd[, eventmask]) Register a file descriptor with the polling object. Future calls to the poll() method will then check whether the file descriptor has any pending I/O events. fd can be either an integer, or an object with a fileno() method that returns an integer. File objects implement fileno(), so ...
python.library.select#select.devpoll.register
devpoll.unregister(fd) Remove a file descriptor being tracked by a polling object. Just like the register() method, fd can be an integer or an object with a fileno() method that returns an integer. Attempting to remove a file descriptor that was never registered is safely ignored.
python.library.select#select.devpoll.unregister
select.epoll(sizehint=-1, flags=0) (Only supported on Linux 2.5.44 and newer.) Return an edge polling object, which can be used as Edge or Level Triggered interface for I/O events. sizehint informs epoll about the expected number of events to be registered. It must be positive, or -1 to use the default. It is only us...
python.library.select#select.epoll
epoll.close() Close the control file descriptor of the epoll object.
python.library.select#select.epoll.close
epoll.closed True if the epoll object is closed.
python.library.select#select.epoll.closed
epoll.fileno() Return the file descriptor number of the control fd.
python.library.select#select.epoll.fileno
epoll.fromfd(fd) Create an epoll object from a given file descriptor.
python.library.select#select.epoll.fromfd
epoll.modify(fd, eventmask) Modify a registered file descriptor.
python.library.select#select.epoll.modify
epoll.poll(timeout=None, maxevents=-1) Wait for events. timeout in seconds (float) Changed in version 3.5: The function is now retried with a recomputed timeout when interrupted by a signal, except if the signal handler raises an exception (see PEP 475 for the rationale), instead of raising InterruptedError.
python.library.select#select.epoll.poll
epoll.register(fd[, eventmask]) Register a fd descriptor with the epoll object.
python.library.select#select.epoll.register
epoll.unregister(fd) Remove a registered file descriptor from the epoll object. Changed in version 3.9: The method no longer ignores the EBADF error.
python.library.select#select.epoll.unregister
exception select.error A deprecated alias of OSError. Changed in version 3.3: Following PEP 3151, this class was made an alias of OSError.
python.library.select#select.error
select.kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0) (Only supported on BSD.) Returns a kernel event object; see section Kevent Objects below for the methods supported by kevent objects.
python.library.select#select.kevent
kevent.data Filter specific data.
python.library.select#select.kevent.data
kevent.fflags Filter specific flags. KQ_FILTER_READ and KQ_FILTER_WRITE filter flags: Constant Meaning KQ_NOTE_LOWAT low water mark of a socket buffer KQ_FILTER_VNODE filter flags: Constant Meaning KQ_NOTE_DELETE unlink() was called KQ_NOTE_WRITE a write occurred KQ_NOTE_EXTEND the file was extended...
python.library.select#select.kevent.fflags
kevent.filter Name of the kernel filter. Constant Meaning KQ_FILTER_READ Takes a descriptor and returns whenever there is data available to read KQ_FILTER_WRITE Takes a descriptor and returns whenever there is data available to write KQ_FILTER_AIO AIO requests KQ_FILTER_VNODE Returns when one or more of t...
python.library.select#select.kevent.filter
kevent.flags Filter action. Constant Meaning KQ_EV_ADD Adds or modifies an event KQ_EV_DELETE Removes an event from the queue KQ_EV_ENABLE Permitscontrol() to returns the event KQ_EV_DISABLE Disablesevent KQ_EV_ONESHOT Removes event after first occurrence KQ_EV_CLEAR Reset the state after an event is ...
python.library.select#select.kevent.flags
kevent.ident Value used to identify the event. The interpretation depends on the filter but it’s usually the file descriptor. In the constructor ident can either be an int or an object with a fileno() method. kevent stores the integer internally.
python.library.select#select.kevent.ident
kevent.udata User defined value.
python.library.select#select.kevent.udata
select.kqueue() (Only supported on BSD.) Returns a kernel queue object; see section Kqueue Objects below for the methods supported by kqueue objects. The new file descriptor is non-inheritable. Changed in version 3.4: The new file descriptor is now non-inheritable.
python.library.select#select.kqueue
kqueue.close() Close the control file descriptor of the kqueue object.
python.library.select#select.kqueue.close
kqueue.closed True if the kqueue object is closed.
python.library.select#select.kqueue.closed
kqueue.control(changelist, max_events[, timeout]) → eventlist Low level interface to kevent changelist must be an iterable of kevent objects or None max_events must be 0 or a positive integer timeout in seconds (floats possible); the default is None, to wait forever Changed in version 3.5: The function is now ret...
python.library.select#select.kqueue.control
kqueue.fileno() Return the file descriptor number of the control fd.
python.library.select#select.kqueue.fileno
kqueue.fromfd(fd) Create a kqueue object from a given file descriptor.
python.library.select#select.kqueue.fromfd
select.PIPE_BUF The minimum number of bytes which can be written without blocking to a pipe when the pipe has been reported as ready for writing by select(), poll() or another interface in this module. This doesn’t apply to other kind of file-like objects such as sockets. This value is guaranteed by POSIX to be at le...
python.library.select#select.PIPE_BUF
select.poll() (Not supported by all operating systems.) Returns a polling object, which supports registering and unregistering file descriptors, and then polling them for I/O events; see section Polling Objects below for the methods supported by polling objects.
python.library.select#select.poll
poll.modify(fd, eventmask) Modifies an already registered fd. This has the same effect as register(fd, eventmask). Attempting to modify a file descriptor that was never registered causes an OSError exception with errno ENOENT to be raised.
python.library.select#select.poll.modify
poll.poll([timeout]) Polls the set of registered file descriptors, and returns a possibly-empty list containing (fd, event) 2-tuples for the descriptors that have events or errors to report. fd is the file descriptor, and event is a bitmask with bits set for the reported events for that descriptor — POLLIN for waitin...
python.library.select#select.poll.poll
poll.register(fd[, eventmask]) Register a file descriptor with the polling object. Future calls to the poll() method will then check whether the file descriptor has any pending I/O events. fd can be either an integer, or an object with a fileno() method that returns an integer. File objects implement fileno(), so the...
python.library.select#select.poll.register
poll.unregister(fd) Remove a file descriptor being tracked by a polling object. Just like the register() method, fd can be an integer or an object with a fileno() method that returns an integer. Attempting to remove a file descriptor that was never registered causes a KeyError exception to be raised.
python.library.select#select.poll.unregister
select.select(rlist, wlist, xlist[, timeout]) This is a straightforward interface to the Unix select() system call. The first three arguments are iterables of ‘waitable objects’: either integers representing file descriptors or objects with a parameterless method named fileno() returning such an integer: rlist: wai...
python.library.select#select.select
selectors — High-level I/O multiplexing New in version 3.4. Source code: Lib/selectors.py Introduction This module allows high-level and efficient I/O multiplexing, built upon the select module primitives. Users are encouraged to use this module instead, unless they want precise control over the OS-level primitives u...
python.library.selectors
class selectors.BaseSelector A BaseSelector is used to wait for I/O event readiness on multiple file objects. It supports file stream registration, unregistration, and a method to wait for I/O events on those streams, with an optional timeout. It’s an abstract base class, so cannot be instantiated. Use DefaultSelecto...
python.library.selectors#selectors.BaseSelector
close() Close the selector. This must be called to make sure that any underlying resource is freed. The selector shall not be used once it has been closed.
python.library.selectors#selectors.BaseSelector.close
get_key(fileobj) Return the key associated with a registered file object. This returns the SelectorKey instance associated to this file object, or raises KeyError if the file object is not registered.
python.library.selectors#selectors.BaseSelector.get_key
abstractmethod get_map() Return a mapping of file objects to selector keys. This returns a Mapping instance mapping registered file objects to their associated SelectorKey instance.
python.library.selectors#selectors.BaseSelector.get_map
modify(fileobj, events, data=None) Change a registered file object’s monitored events or attached data. This is equivalent to BaseSelector.unregister(fileobj)() followed by BaseSelector.register(fileobj, events, data)(), except that it can be implemented more efficiently. This returns a new SelectorKey instance, or r...
python.library.selectors#selectors.BaseSelector.modify
abstractmethod register(fileobj, events, data=None) Register a file object for selection, monitoring it for I/O events. fileobj is the file object to monitor. It may either be an integer file descriptor or an object with a fileno() method. events is a bitwise mask of events to monitor. data is an opaque object. This ...
python.library.selectors#selectors.BaseSelector.register
abstractmethod select(timeout=None) Wait until some registered file objects become ready, or the timeout expires. If timeout > 0, this specifies the maximum wait time, in seconds. If timeout <= 0, the call won’t block, and will report the currently ready file objects. If timeout is None, the call will block until a m...
python.library.selectors#selectors.BaseSelector.select
abstractmethod unregister(fileobj) Unregister a file object from selection, removing it from monitoring. A file object shall be unregistered prior to being closed. fileobj must be a file object previously registered. This returns the associated SelectorKey instance, or raises a KeyError if fileobj is not registered. ...
python.library.selectors#selectors.BaseSelector.unregister
class selectors.DefaultSelector The default selector class, using the most efficient implementation available on the current platform. This should be the default choice for most users.
python.library.selectors#selectors.DefaultSelector
class selectors.DevpollSelector select.devpoll()-based selector. fileno() This returns the file descriptor used by the underlying select.devpoll() object. New in version 3.5.
python.library.selectors#selectors.DevpollSelector
fileno() This returns the file descriptor used by the underlying select.devpoll() object.
python.library.selectors#selectors.DevpollSelector.fileno
class selectors.EpollSelector select.epoll()-based selector. fileno() This returns the file descriptor used by the underlying select.epoll() object.
python.library.selectors#selectors.EpollSelector
fileno() This returns the file descriptor used by the underlying select.epoll() object.
python.library.selectors#selectors.EpollSelector.fileno
class selectors.KqueueSelector select.kqueue()-based selector. fileno() This returns the file descriptor used by the underlying select.kqueue() object.
python.library.selectors#selectors.KqueueSelector
fileno() This returns the file descriptor used by the underlying select.kqueue() object.
python.library.selectors#selectors.KqueueSelector.fileno
class selectors.PollSelector select.poll()-based selector.
python.library.selectors#selectors.PollSelector
class selectors.SelectorKey A SelectorKey is a namedtuple used to associate a file object to its underlying file descriptor, selected event mask and attached data. It is returned by several BaseSelector methods. fileobj File object registered. fd Underlying file descriptor. events Events that must be ...
python.library.selectors#selectors.SelectorKey
data Optional opaque data associated to this file object: for example, this could be used to store a per-client session ID.
python.library.selectors#selectors.SelectorKey.data
events Events that must be waited for on this file object.
python.library.selectors#selectors.SelectorKey.events
fd Underlying file descriptor.
python.library.selectors#selectors.SelectorKey.fd
fileobj File object registered.
python.library.selectors#selectors.SelectorKey.fileobj
class selectors.SelectSelector select.select()-based selector.
python.library.selectors#selectors.SelectSelector
class set([iterable]) Return a new set object, optionally with elements taken from iterable. set is a built-in class. See set and Set Types — set, frozenset for documentation about this class. For other containers see the built-in frozenset, list, tuple, and dict classes, as well as the collections module.
python.library.functions#set
class set([iterable]) class frozenset([iterable]) Return a new set or frozenset object whose elements are taken from iterable. The elements of a set must be hashable. To represent sets of sets, the inner sets must be frozenset objects. If iterable is not specified, a new empty set is returned. Sets can be created b...
python.library.stdtypes#set
setattr(object, name, value) This is the counterpart of getattr(). The arguments are an object, a string and an arbitrary value. The string may name an existing attribute or a new attribute. The function assigns the value to the attribute, provided the object allows it. For example, setattr(x, 'foobar', 123) is equiv...
python.library.functions#setattr
shelve — Python object persistence Source code: Lib/shelve.py A “shelf” is a persistent, dictionary-like object. The difference with “dbm” databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects — anything that the pickle module can handle. This includes most class instances,...
python.library.shelve
class shelve.BsdDbShelf(dict, protocol=None, writeback=False, keyencoding='utf-8') A subclass of Shelf which exposes first(), next(), previous(), last() and set_location() which are available in the third-party bsddb module from pybsddb but not in other database modules. The dict object passed to the constructor must...
python.library.shelve#shelve.BsdDbShelf
class shelve.DbfilenameShelf(filename, flag='c', protocol=None, writeback=False) A subclass of Shelf which accepts a filename instead of a dict-like object. The underlying file will be opened using dbm.open(). By default, the file will be created and opened for both read and write. The optional flag parameter has the...
python.library.shelve#shelve.DbfilenameShelf
shelve.open(filename, flag='c', protocol=None, writeback=False) Open a persistent dictionary. The filename specified is the base filename for the underlying database. As a side-effect, an extension may be added to the filename and more than one file may be created. By default, the underlying database file is opened f...
python.library.shelve#shelve.open
class shelve.Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8') A subclass of collections.abc.MutableMapping which stores pickled values in the dict object. By default, version 3 pickles are used to serialize values. The version of the pickle protocol can be specified with the protocol parameter. See th...
python.library.shelve#shelve.Shelf
Shelf.close() Synchronize and close the persistent dict object. Operations on a closed shelf will fail with a ValueError.
python.library.shelve#shelve.Shelf.close
Shelf.sync() Write back all entries in the cache if the shelf was opened with writeback set to True. Also empty the cache and synchronize the persistent dictionary on disk, if feasible. This is called automatically when the shelf is closed with close().
python.library.shelve#shelve.Shelf.sync
shlex — Simple lexical analysis Source code: Lib/shlex.py The shlex class makes it easy to write lexical analyzers for simple syntaxes resembling that of the Unix shell. This will often be useful for writing minilanguages, (for example, in run control files for Python applications) or for parsing quoted strings. The sh...
python.library.shlex
shlex.join(split_command) Concatenate the tokens of the list split_command and return a string. This function is the inverse of split(). >>> from shlex import join >>> print(join(['echo', '-n', 'Multiple words'])) echo -n 'Multiple words' The returned value is shell-escaped to protect against injection vulnerabiliti...
python.library.shlex#shlex.join