doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
lngettext(singular, plural, n) Equivalent to gettext() and ngettext(), but the translation is returned as a byte string encoded in the preferred system encoding if no encoding was explicitly set with set_output_charset(). Warning These methods should be avoided in Python 3. See the warning for the lgettext() functio...
python.library.gettext#gettext.GNUTranslations.lngettext
ngettext(singular, plural, n) Do a plural-forms lookup of a message id. singular is used as the message id for purposes of lookup in the catalog, while n is used to determine which plural form to use. The returned message string is a Unicode string. If the message id is not found in the catalog, and a fallback is spe...
python.library.gettext#gettext.GNUTranslations.ngettext
npgettext(context, singular, plural, n) Do a plural-forms lookup of a message id. singular is used as the message id for purposes of lookup in the catalog, while n is used to determine which plural form to use. If the message id for context is not found in the catalog, and a fallback is specified, the request is forw...
python.library.gettext#gettext.GNUTranslations.npgettext
pgettext(context, message) Look up the context and message id in the catalog and return the corresponding message string, as a Unicode string. If there is no entry in the catalog for the message id and context, and a fallback has been set, the look up is forwarded to the fallback’s pgettext() method. Otherwise, the m...
python.library.gettext#gettext.GNUTranslations.pgettext
gettext.install(domain, localedir=None, codeset=None, names=None) This installs the function _() in Python’s builtins namespace, based on domain, localedir, and codeset which are passed to the function translation(). For the names parameter, please see the description of the translation object’s install() method. As ...
python.library.gettext#gettext.install
gettext.ldgettext(domain, message)
python.library.gettext#gettext.ldgettext
gettext.ldngettext(domain, singular, plural, n) Equivalent to the corresponding functions without the l prefix (gettext(), dgettext(), ngettext() and dngettext()), but the translation is returned as a byte string encoded in the preferred system encoding if no other encoding was explicitly set with bind_textdomain_cod...
python.library.gettext#gettext.ldngettext
gettext.lgettext(message)
python.library.gettext#gettext.lgettext
gettext.lngettext(singular, plural, n)
python.library.gettext#gettext.lngettext
gettext.ngettext(singular, plural, n) Like gettext(), but consider plural forms. If a translation is found, apply the plural formula to n, and return the resulting message (some languages have more than two plural forms). If no translation is found, return singular if n is 1; return plural otherwise. The Plural formu...
python.library.gettext#gettext.ngettext
gettext.npgettext(context, singular, plural, n)
python.library.gettext#gettext.npgettext
class gettext.NullTranslations(fp=None) Takes an optional file object fp, which is ignored by the base class. Initializes “protected” instance variables _info and _charset which are set by derived classes, as well as _fallback, which is set through add_fallback(). It then calls self._parse(fp) if fp is not None. _p...
python.library.gettext#gettext.NullTranslations
add_fallback(fallback) Add fallback as the fallback object for the current translation object. A translation object should consult the fallback if it cannot provide a translation for a given message.
python.library.gettext#gettext.NullTranslations.add_fallback
charset() Return the encoding of the message catalog file.
python.library.gettext#gettext.NullTranslations.charset
gettext(message) If a fallback has been set, forward gettext() to the fallback. Otherwise, return message. Overridden in derived classes.
python.library.gettext#gettext.NullTranslations.gettext
info() Return the “protected” _info variable, a dictionary containing the metadata found in the message catalog file.
python.library.gettext#gettext.NullTranslations.info
install(names=None) This method installs gettext() into the built-in namespace, binding it to _. If the names parameter is given, it must be a sequence containing the names of functions you want to install in the builtins namespace in addition to _(). Supported names are 'gettext', 'ngettext', 'pgettext', 'npgettext'...
python.library.gettext#gettext.NullTranslations.install
lgettext(message)
python.library.gettext#gettext.NullTranslations.lgettext
lngettext(singular, plural, n) Equivalent to gettext() and ngettext(), but the translation is returned as a byte string encoded in the preferred system encoding if no encoding was explicitly set with set_output_charset(). Overridden in derived classes. Warning These methods should be avoided in Python 3. See the war...
python.library.gettext#gettext.NullTranslations.lngettext
ngettext(singular, plural, n) If a fallback has been set, forward ngettext() to the fallback. Otherwise, return singular if n is 1; return plural otherwise. Overridden in derived classes.
python.library.gettext#gettext.NullTranslations.ngettext
npgettext(context, singular, plural, n) If a fallback has been set, forward npgettext() to the fallback. Otherwise, return the translated message. Overridden in derived classes. New in version 3.8.
python.library.gettext#gettext.NullTranslations.npgettext
output_charset() Return the encoding used to return translated messages in lgettext() and lngettext(). Deprecated since version 3.8, will be removed in version 3.10.
python.library.gettext#gettext.NullTranslations.output_charset
pgettext(context, message) If a fallback has been set, forward pgettext() to the fallback. Otherwise, return the translated message. Overridden in derived classes. New in version 3.8.
python.library.gettext#gettext.NullTranslations.pgettext
set_output_charset(charset) Change the encoding used to return translated messages. Deprecated since version 3.8, will be removed in version 3.10.
python.library.gettext#gettext.NullTranslations.set_output_charset
_parse(fp) No-op in the base class, this method takes file object fp, and reads the data from the file, initializing its message catalog. If you have an unsupported message catalog file format, you should override this method to parse your format.
python.library.gettext#gettext.NullTranslations._parse
gettext.pgettext(context, message)
python.library.gettext#gettext.pgettext
gettext.textdomain(domain=None) Change or query the current global domain. If domain is None, then the current global domain is returned, otherwise the global domain is set to domain, which is returned.
python.library.gettext#gettext.textdomain
gettext.translation(domain, localedir=None, languages=None, class_=None, fallback=False, codeset=None) Return a *Translations instance based on the domain, localedir, and languages, which are first passed to find() to get a list of the associated .mo file paths. Instances with identical .mo file names are cached. The...
python.library.gettext#gettext.translation
glob — Unix style pathname pattern expansion Source code: Lib/glob.py The glob module finds all the pathnames matching a specified pattern according to the rules used by the Unix shell, although results are returned in arbitrary order. No tilde expansion is done, but *, ?, and character ranges expressed with [] will be...
python.library.glob
glob.escape(pathname) Escape all special characters ('?', '*' and '['). This is useful if you want to match an arbitrary literal string that may have special characters in it. Special characters in drive/UNC sharepoints are not escaped, e.g. on Windows escape('//?/c:/Quo vadis?.txt') returns '//?/c:/Quo vadis[?].txt'...
python.library.glob#glob.escape
glob.glob(pathname, *, recursive=False) Return a possibly-empty list of path names that match pathname, which must be a string containing a path specification. pathname can be either absolute (like /usr/src/Python-1.5/Makefile) or relative (like ../../Tools/*/*.gif), and can contain shell-style wildcards. Broken syml...
python.library.glob#glob.glob
glob.iglob(pathname, *, recursive=False) Return an iterator which yields the same values as glob() without actually storing them all simultaneously. Raises an auditing event glob.glob with arguments pathname, recursive.
python.library.glob#glob.iglob
globals() Return a dictionary representing the current global symbol table. This is always the dictionary of the current module (inside a function or method, this is the module where it is defined, not the module from which it is called).
python.library.functions#globals
graphlib — Functionality to operate with graph-like structures Source code: Lib/graphlib.py class graphlib.TopologicalSorter(graph=None) Provides functionality to topologically sort a graph of hashable nodes. A topological order is a linear ordering of the vertices in a graph such that for every directed edge u -> ...
python.library.graphlib
exception graphlib.CycleError Subclass of ValueError raised by TopologicalSorter.prepare() if cycles exist in the working graph. If multiple cycles exist, only one undefined choice among them will be reported and included in the exception. The detected cycle can be accessed via the second element in the args attribut...
python.library.graphlib#graphlib.CycleError
class graphlib.TopologicalSorter(graph=None) Provides functionality to topologically sort a graph of hashable nodes. A topological order is a linear ordering of the vertices in a graph such that for every directed edge u -> v from vertex u to vertex v, vertex u comes before vertex v in the ordering. For instance, the...
python.library.graphlib#graphlib.TopologicalSorter
add(node, *predecessors) Add a new node and its predecessors to the graph. Both the node and all elements in predecessors must be hashable. If called multiple times with the same node argument, the set of dependencies will be the union of all dependencies passed in. It is possible to add a node with no dependencies (...
python.library.graphlib#graphlib.TopologicalSorter.add
done(*nodes) Marks a set of nodes returned by TopologicalSorter.get_ready() as processed, unblocking any successor of each node in nodes for being returned in the future by a call to TopologicalSorter.get_ready(). Raises ValueError if any node in nodes has already been marked as processed by a previous call to this m...
python.library.graphlib#graphlib.TopologicalSorter.done
get_ready() Returns a tuple with all the nodes that are ready. Initially it returns all nodes with no predecessors, and once those are marked as processed by calling TopologicalSorter.done(), further calls will return all new nodes that have all their predecessors already processed. Once no more progress can be made,...
python.library.graphlib#graphlib.TopologicalSorter.get_ready
is_active() Returns True if more progress can be made and False otherwise. Progress can be made if cycles do not block the resolution and either there are still nodes ready that haven’t yet been returned by TopologicalSorter.get_ready() or the number of nodes marked TopologicalSorter.done() is less than the number th...
python.library.graphlib#graphlib.TopologicalSorter.is_active
prepare() Mark the graph as finished and check for cycles in the graph. If any cycle is detected, CycleError will be raised, but get_ready() can still be used to obtain as many nodes as possible until cycles block more progress. After a call to this function, the graph cannot be modified, and therefore no more nodes ...
python.library.graphlib#graphlib.TopologicalSorter.prepare
static_order() Returns an iterable of nodes in a topological order. Using this method does not require to call TopologicalSorter.prepare() or TopologicalSorter.done(). This method is equivalent to: def static_order(self): self.prepare() while self.is_active(): node_group = self.get_ready() yie...
python.library.graphlib#graphlib.TopologicalSorter.static_order
grp — The group database This module provides access to the Unix group database. It is available on all Unix versions. Group database entries are reported as a tuple-like object, whose attributes correspond to the members of the group structure (Attribute field below, see <pwd.h>): Index Attribute Meaning 0 gr_na...
python.library.grp
grp.getgrall() Return a list of all available group entries, in arbitrary order.
python.library.grp#grp.getgrall
grp.getgrgid(gid) Return the group database entry for the given numeric group ID. KeyError is raised if the entry asked for cannot be found. Deprecated since version 3.6: Since Python 3.6 the support of non-integer arguments like floats or strings in getgrgid() is deprecated.
python.library.grp#grp.getgrgid
grp.getgrnam(name) Return the group database entry for the given group name. KeyError is raised if the entry asked for cannot be found.
python.library.grp#grp.getgrnam
gzip — Support for gzip files Source code: Lib/gzip.py This module provides a simple interface to compress and decompress files just like the GNU programs gzip and gunzip would. The data compression is provided by the zlib module. The gzip module provides the GzipFile class, as well as the open(), compress() and decomp...
python.library.gzip
exception gzip.BadGzipFile An exception raised for invalid gzip files. It inherits OSError. EOFError and zlib.error can also be raised for invalid gzip files. New in version 3.8.
python.library.gzip#gzip.BadGzipFile
gzip.compress(data, compresslevel=9, *, mtime=None) Compress the data, returning a bytes object containing the compressed data. compresslevel and mtime have the same meaning as in the GzipFile constructor above. New in version 3.2. Changed in version 3.8: Added the mtime parameter for reproducible output.
python.library.gzip#gzip.compress
gzip.decompress(data) Decompress the data, returning a bytes object containing the uncompressed data. New in version 3.2.
python.library.gzip#gzip.decompress
class gzip.GzipFile(filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None) Constructor for the GzipFile class, which simulates most of the methods of a file object, with the exception of the truncate() method. At least one of fileobj and filename must be given a non-trivial value. The new class instance...
python.library.gzip#gzip.GzipFile
mtime When decompressing, the value of the last modification time field in the most recently read header may be read from this attribute, as an integer. The initial value before reading any headers is None. All gzip compressed streams are required to contain this timestamp field. Some programs, such as gunzip, make u...
python.library.gzip#gzip.GzipFile.mtime
peek(n) Read n uncompressed bytes without advancing the file position. At most one single read on the compressed stream is done to satisfy the call. The number of bytes returned may be more or less than requested. Note While calling peek() does not change the file position of the GzipFile, it may change the position...
python.library.gzip#gzip.GzipFile.peek
gzip.open(filename, mode='rb', compresslevel=9, encoding=None, errors=None, newline=None) Open a gzip-compressed file in binary or text mode, returning a file object. The filename argument can be an actual filename (a str or bytes object), or an existing file object to read from or write to. The mode argument can be ...
python.library.gzip#gzip.open
hasattr(object, name) The arguments are an object and a string. The result is True if the string is the name of one of the object’s attributes, False if not. (This is implemented by calling getattr(object, name) and seeing whether it raises an AttributeError or not.)
python.library.functions#hasattr
hash(object) Return the hash value of the object (if it has one). Hash values are integers. They are used to quickly compare dictionary keys during a dictionary lookup. Numeric values that compare equal have the same hash value (even if they are of different types, as is the case for 1 and 1.0). Note For objects wit...
python.library.functions#hash
hashlib — Secure hashes and message digests Source code: Lib/hashlib.py This module implements a common interface to many different secure hash and message digest algorithms. Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512 (defined in FIPS 180-2) as well as RSA’s MD5 algorithm (def...
python.library.hashlib
hashlib.algorithms_available A set containing the names of the hash algorithms that are available in the running Python interpreter. These names will be recognized when passed to new(). algorithms_guaranteed will always be a subset. The same algorithm may appear multiple times in this set under different names (thank...
python.library.hashlib#hashlib.algorithms_available
hashlib.algorithms_guaranteed A set containing the names of the hash algorithms guaranteed to be supported by this module on all platforms. Note that ‘md5’ is in this list despite some upstream vendors offering an odd “FIPS compliant” Python build that excludes it. New in version 3.2.
python.library.hashlib#hashlib.algorithms_guaranteed
hashlib.blake2b(data=b'', *, digest_size=64, key=b'', salt=b'', person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, node_depth=0, inner_size=0, last_node=False, usedforsecurity=True)
python.library.hashlib#hashlib.blake2b
blake2b.MAX_DIGEST_SIZE
python.library.hashlib#hashlib.blake2b.MAX_DIGEST_SIZE
blake2b.MAX_KEY_SIZE
python.library.hashlib#hashlib.blake2b.MAX_KEY_SIZE
blake2b.PERSON_SIZE
python.library.hashlib#hashlib.blake2b.PERSON_SIZE
blake2b.SALT_SIZE
python.library.hashlib#hashlib.blake2b.SALT_SIZE
hashlib.blake2s(data=b'', *, digest_size=32, key=b'', salt=b'', person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, node_depth=0, inner_size=0, last_node=False, usedforsecurity=True)
python.library.hashlib#hashlib.blake2s
blake2s.MAX_DIGEST_SIZE
python.library.hashlib#hashlib.blake2s.MAX_DIGEST_SIZE
blake2s.MAX_KEY_SIZE
python.library.hashlib#hashlib.blake2s.MAX_KEY_SIZE
blake2s.PERSON_SIZE
python.library.hashlib#hashlib.blake2s.PERSON_SIZE
blake2s.SALT_SIZE
python.library.hashlib#hashlib.blake2s.SALT_SIZE
hash.block_size The internal block size of the hash algorithm in bytes.
python.library.hashlib#hashlib.hash.block_size
hash.copy() Return a copy (“clone”) of the hash object. This can be used to efficiently compute the digests of data sharing a common initial substring.
python.library.hashlib#hashlib.hash.copy
hash.digest() Return the digest of the data passed to the update() method so far. This is a bytes object of size digest_size which may contain bytes in the whole range from 0 to 255.
python.library.hashlib#hashlib.hash.digest
hash.digest_size The size of the resulting hash in bytes.
python.library.hashlib#hashlib.hash.digest_size
hash.hexdigest() Like digest() except the digest is returned as a string object of double length, containing only hexadecimal digits. This may be used to exchange the value safely in email or other non-binary environments.
python.library.hashlib#hashlib.hash.hexdigest
hash.name The canonical name of this hash, always lowercase and always suitable as a parameter to new() to create another hash of this type. Changed in version 3.4: The name attribute has been present in CPython since its inception, but until Python 3.4 was not formally specified, so may not exist on some platforms.
python.library.hashlib#hashlib.hash.name
hash.update(data) Update the hash object with the bytes-like object. Repeated calls are equivalent to a single call with the concatenation of all the arguments: m.update(a); m.update(b) is equivalent to m.update(a+b). Changed in version 3.1: The Python GIL is released to allow other threads to run while hash updates...
python.library.hashlib#hashlib.hash.update
hashlib.new(name, [data, ]*, usedforsecurity=True) Is a generic constructor that takes the string name of the desired algorithm as its first parameter. It also exists to allow access to the above listed hashes as well as any other algorithms that your OpenSSL library may offer. The named constructors are much faster ...
python.library.hashlib#hashlib.new
hashlib.pbkdf2_hmac(hash_name, password, salt, iterations, dklen=None) The function provides PKCS#5 password-based key derivation function 2. It uses HMAC as pseudorandom function. The string hash_name is the desired name of the hash digest algorithm for HMAC, e.g. ‘sha1’ or ‘sha256’. password and salt are interprete...
python.library.hashlib#hashlib.pbkdf2_hmac
hashlib.scrypt(password, *, salt, n, r, p, maxmem=0, dklen=64) The function provides scrypt password-based key derivation function as defined in RFC 7914. password and salt must be bytes-like objects. Applications and libraries should limit password to a sensible length (e.g. 1024). salt should be about 16 or more by...
python.library.hashlib#hashlib.scrypt
shake.digest(length) Return the digest of the data passed to the update() method so far. This is a bytes object of size length which may contain bytes in the whole range from 0 to 255.
python.library.hashlib#hashlib.shake.digest
shake.hexdigest(length) Like digest() except the digest is returned as a string object of double length, containing only hexadecimal digits. This may be used to exchange the value safely in email or other non-binary environments.
python.library.hashlib#hashlib.shake.hexdigest
heapq — Heap queue algorithm Source code: Lib/heapq.py This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm. Heaps are binary trees for which every parent node has a value less than or equal to any of its children. This implementation uses arrays for which heap[...
python.library.heapq
heapq.heapify(x) Transform list x into a heap, in-place, in linear time.
python.library.heapq#heapq.heapify
heapq.heappop(heap) Pop and return the smallest item from the heap, maintaining the heap invariant. If the heap is empty, IndexError is raised. To access the smallest item without popping it, use heap[0].
python.library.heapq#heapq.heappop
heapq.heappush(heap, item) Push the value item onto the heap, maintaining the heap invariant.
python.library.heapq#heapq.heappush
heapq.heappushpop(heap, item) Push item on the heap, then pop and return the smallest item from the heap. The combined action runs more efficiently than heappush() followed by a separate call to heappop().
python.library.heapq#heapq.heappushpop
heapq.heapreplace(heap, item) Pop and return the smallest item from the heap, and also push the new item. The heap size doesn’t change. If the heap is empty, IndexError is raised. This one step operation is more efficient than a heappop() followed by heappush() and can be more appropriate when using a fixed-size heap...
python.library.heapq#heapq.heapreplace
heapq.merge(*iterables, key=None, reverse=False) Merge multiple sorted inputs into a single sorted output (for example, merge timestamped entries from multiple log files). Returns an iterator over the sorted values. Similar to sorted(itertools.chain(*iterables)) but returns an iterable, does not pull the data into me...
python.library.heapq#heapq.merge
heapq.nlargest(n, iterable, key=None) Return a list with the n largest elements from the dataset defined by iterable. key, if provided, specifies a function of one argument that is used to extract a comparison key from each element in iterable (for example, key=str.lower). Equivalent to: sorted(iterable, key=key, rev...
python.library.heapq#heapq.nlargest
heapq.nsmallest(n, iterable, key=None) Return a list with the n smallest elements from the dataset defined by iterable. key, if provided, specifies a function of one argument that is used to extract a comparison key from each element in iterable (for example, key=str.lower). Equivalent to: sorted(iterable, key=key)[:...
python.library.heapq#heapq.nsmallest
help([object]) Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation...
python.library.functions#help
hex(x) Convert an integer number to a lowercase hexadecimal string prefixed with “0x”. If x is not a Python int object, it has to define an __index__() method that returns an integer. Some examples: >>> hex(255) '0xff' >>> hex(-42) '-0x2a' If you want to convert an integer number to an uppercase or lower hexadecimal...
python.library.functions#hex
hmac — Keyed-Hashing for Message Authentication Source code: Lib/hmac.py This module implements the HMAC algorithm as described by RFC 2104. hmac.new(key, msg=None, digestmod='') Return a new hmac object. key is a bytes or bytearray object giving the secret key. If msg is present, the method call update(msg) is mad...
python.library.hmac
hmac.compare_digest(a, b) Return a == b. This function uses an approach designed to prevent timing analysis by avoiding content-based short circuiting behaviour, making it appropriate for cryptography. a and b must both be of the same type: either str (ASCII only, as e.g. returned by HMAC.hexdigest()), or a bytes-lik...
python.library.hmac#hmac.compare_digest
hmac.digest(key, msg, digest) Return digest of msg for given secret key and digest. The function is equivalent to HMAC(key, msg, digest).digest(), but uses an optimized C or inline implementation, which is faster for messages that fit into memory. The parameters key, msg, and digest have the same meaning as in new()....
python.library.hmac#hmac.digest
HMAC.block_size The internal block size of the hash algorithm in bytes. New in version 3.4.
python.library.hmac#hmac.HMAC.block_size
HMAC.copy() Return a copy (“clone”) of the hmac object. This can be used to efficiently compute the digests of strings that share a common initial substring.
python.library.hmac#hmac.HMAC.copy
HMAC.digest() Return the digest of the bytes passed to the update() method so far. This bytes object will be the same length as the digest_size of the digest given to the constructor. It may contain non-ASCII bytes, including NUL bytes. Warning When comparing the output of digest() to an externally-supplied digest d...
python.library.hmac#hmac.HMAC.digest
HMAC.digest_size The size of the resulting HMAC digest in bytes.
python.library.hmac#hmac.HMAC.digest_size
HMAC.hexdigest() Like digest() except the digest is returned as a string twice the length containing only hexadecimal digits. This may be used to exchange the value safely in email or other non-binary environments. Warning When comparing the output of hexdigest() to an externally-supplied digest during a verificatio...
python.library.hmac#hmac.HMAC.hexdigest