doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
iterator.__next__()
Return the next item from the container. If there are no further items, raise the StopIteration exception. This method corresponds to the tp_iternext slot of the type structure for Python objects in the Python/C API. | python.library.stdtypes#iterator.__next__ |
itertools — Functions creating iterators for efficient looping This module implements a number of iterator building blocks inspired by constructs from APL, Haskell, and SML. Each has been recast in a form suitable for Python. The module standardizes a core set of fast, memory efficient tools that are useful by themselv... | python.library.itertools |
itertools.accumulate(iterable[, func, *, initial=None])
Make an iterator that returns accumulated sums, or accumulated results of other binary functions (specified via the optional func argument). If func is supplied, it should be a function of two arguments. Elements of the input iterable may be any type that can be... | python.library.itertools#itertools.accumulate |
itertools.chain(*iterables)
Make an iterator that returns elements from the first iterable until it is exhausted, then proceeds to the next iterable, until all of the iterables are exhausted. Used for treating consecutive sequences as a single sequence. Roughly equivalent to: def chain(*iterables):
# chain('ABC',... | python.library.itertools#itertools.chain |
classmethod chain.from_iterable(iterable)
Alternate constructor for chain(). Gets chained inputs from a single iterable argument that is evaluated lazily. Roughly equivalent to: def from_iterable(iterables):
# chain.from_iterable(['ABC', 'DEF']) --> A B C D E F
for it in iterables:
for element in it:
... | python.library.itertools#itertools.chain.from_iterable |
itertools.combinations(iterable, r)
Return r length subsequences of elements from the input iterable. The combination tuples are emitted in lexicographic ordering according to the order of the input iterable. So, if the input iterable is sorted, the combination tuples will be produced in sorted order. Elements are tr... | python.library.itertools#itertools.combinations |
itertools.combinations_with_replacement(iterable, r)
Return r length subsequences of elements from the input iterable allowing individual elements to be repeated more than once. The combination tuples are emitted in lexicographic ordering according to the order of the input iterable. So, if the input iterable is sort... | python.library.itertools#itertools.combinations_with_replacement |
itertools.compress(data, selectors)
Make an iterator that filters elements from data returning only those that have a corresponding element in selectors that evaluates to True. Stops when either the data or selectors iterables has been exhausted. Roughly equivalent to: def compress(data, selectors):
# compress('A... | python.library.itertools#itertools.compress |
itertools.count(start=0, step=1)
Make an iterator that returns evenly spaced values starting with number start. Often used as an argument to map() to generate consecutive data points. Also, used with zip() to add sequence numbers. Roughly equivalent to: def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 .... | python.library.itertools#itertools.count |
itertools.cycle(iterable)
Make an iterator returning elements from the iterable and saving a copy of each. When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely. Roughly equivalent to: def cycle(iterable):
# cycle('ABCD') --> A B C D A B C D A B C D ...
saved = []
for e... | python.library.itertools#itertools.cycle |
itertools.dropwhile(predicate, iterable)
Make an iterator that drops elements from the iterable as long as the predicate is true; afterwards, returns every element. Note, the iterator does not produce any output until the predicate first becomes false, so it may have a lengthy start-up time. Roughly equivalent to: de... | python.library.itertools#itertools.dropwhile |
itertools.filterfalse(predicate, iterable)
Make an iterator that filters elements from iterable returning only those for which the predicate is False. If predicate is None, return the items that are false. Roughly equivalent to: def filterfalse(predicate, iterable):
# filterfalse(lambda x: x%2, range(10)) --> 0 2... | python.library.itertools#itertools.filterfalse |
itertools.groupby(iterable, key=None)
Make an iterator that returns consecutive keys and groups from the iterable. The key is a function computing a key value for each element. If not specified or is None, key defaults to an identity function and returns the element unchanged. Generally, the iterable needs to already... | python.library.itertools#itertools.groupby |
itertools.islice(iterable, stop)
itertools.islice(iterable, start, stop[, step])
Make an iterator that returns selected elements from the iterable. If start is non-zero, then elements from the iterable are skipped until start is reached. Afterward, elements are returned consecutively unless step is set higher than ... | python.library.itertools#itertools.islice |
itertools.permutations(iterable, r=None)
Return successive r length permutations of elements in the iterable. If r is not specified or is None, then r defaults to the length of the iterable and all possible full-length permutations are generated. The permutation tuples are emitted in lexicographic ordering according ... | python.library.itertools#itertools.permutations |
itertools.product(*iterables, repeat=1)
Cartesian product of input iterables. Roughly equivalent to nested for-loops in a generator expression. For example, product(A, B) returns the same as ((x,y) for x in A for y in B). The nested loops cycle like an odometer with the rightmost element advancing on every iteration.... | python.library.itertools#itertools.product |
itertools.repeat(object[, times])
Make an iterator that returns object over and over again. Runs indefinitely unless the times argument is specified. Used as argument to map() for invariant parameters to the called function. Also used with zip() to create an invariant part of a tuple record. Roughly equivalent to: de... | python.library.itertools#itertools.repeat |
itertools.starmap(function, iterable)
Make an iterator that computes the function using arguments obtained from the iterable. Used instead of map() when argument parameters are already grouped in tuples from a single iterable (the data has been “pre-zipped”). The difference between map() and starmap() parallels the d... | python.library.itertools#itertools.starmap |
itertools.takewhile(predicate, iterable)
Make an iterator that returns elements from the iterable as long as the predicate is true. Roughly equivalent to: def takewhile(predicate, iterable):
# takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4
for x in iterable:
if predicate(x):
yield x
... | python.library.itertools#itertools.takewhile |
itertools.tee(iterable, n=2)
Return n independent iterators from a single iterable. The following Python code helps explain what tee does (although the actual implementation is more complex and uses only a single underlying FIFO queue). Roughly equivalent to: def tee(iterable, n=2):
it = iter(iterable)
deques... | python.library.itertools#itertools.tee |
itertools.zip_longest(*iterables, fillvalue=None)
Make an iterator that aggregates elements from each of the iterables. If the iterables are of uneven length, missing values are filled-in with fillvalue. Iteration continues until the longest iterable is exhausted. Roughly equivalent to: def zip_longest(*args, fillval... | python.library.itertools#itertools.zip_longest |
json — JSON encoder and decoder Source code: Lib/json/__init__.py JSON (JavaScript Object Notation), specified by RFC 7159 (which obsoletes RFC 4627) and by ECMA-404, is a lightweight data interchange format inspired by JavaScript object literal syntax (although it is not a strict subset of JavaScript 1 ). json exposes... | python.library.json |
json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)
Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object) using this conversion table. If skipkeys is true (default: ... | python.library.json#json.dump |
json.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)
Serialize obj to a JSON formatted str using this conversion table. The arguments have the same meaning as in dump(). Note Keys in key/value pairs of ... | python.library.json#json.dumps |
exception json.JSONDecodeError(msg, doc, pos)
Subclass of ValueError with the following additional attributes:
msg
The unformatted error message.
doc
The JSON document being parsed.
pos
The start index of doc where parsing failed.
lineno
The line corresponding to pos.
colno
The column corr... | python.library.json#json.JSONDecodeError |
colno
The column corresponding to pos. | python.library.json#json.JSONDecodeError.colno |
doc
The JSON document being parsed. | python.library.json#json.JSONDecodeError.doc |
lineno
The line corresponding to pos. | python.library.json#json.JSONDecodeError.lineno |
msg
The unformatted error message. | python.library.json#json.JSONDecodeError.msg |
pos
The start index of doc where parsing failed. | python.library.json#json.JSONDecodeError.pos |
class json.JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
Simple JSON decoder. Performs the following translations in decoding by default:
JSON Python
object dict
array list
string str
number (int) int
number (real) float
tr... | python.library.json#json.JSONDecoder |
decode(s)
Return the Python representation of s (a str instance containing a JSON document). JSONDecodeError will be raised if the given JSON document is not valid. | python.library.json#json.JSONDecoder.decode |
raw_decode(s)
Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended. This can be used to decode a JSON document from a string that may have extraneous data at the end. | python.library.json#json.JSONDecoder.raw_decode |
class json.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Extensible JSON encoder for Python data structures. Supports the following objects and types by default:
Python JSON
dict object
list, tuple array
st... | python.library.json#json.JSONEncoder |
default(o)
Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError). For example, to support arbitrary iterators, you could implement default() like this: def default(self, o):
try:
iterable = iter(o)
except TypeError:
... | python.library.json#json.JSONEncoder.default |
encode(o)
Return a JSON string representation of a Python data structure, o. For example: >>> json.JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo": ["bar", "baz"]}' | python.library.json#json.JSONEncoder.encode |
iterencode(o)
Encode the given object, o, and yield each string representation as available. For example: for chunk in json.JSONEncoder().iterencode(bigobject):
mysocket.write(chunk) | python.library.json#json.JSONEncoder.iterencode |
json.load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize fp (a .read()-supporting text file or binary file containing a JSON document) to a Python object using this conversion table. object_hook is an optional function that will be c... | python.library.json#json.load |
json.loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize s (a str, bytes or bytearray instance containing a JSON document) to a Python object using this conversion table. The other arguments have the same meaning as in load(). If the... | python.library.json#json.loads |
exception KeyboardInterrupt
Raised when the user hits the interrupt key (normally Control-C or Delete). During execution, a check for interrupts is made regularly. The exception inherits from BaseException so as to not be accidentally caught by code that catches Exception and thus prevent the interpreter from exiting... | python.library.exceptions#KeyboardInterrupt |
exception KeyError
Raised when a mapping (dictionary) key is not found in the set of existing keys. | python.library.exceptions#KeyError |
keyword — Testing for Python keywords Source code: Lib/keyword.py This module allows a Python program to determine if a string is a keyword.
keyword.iskeyword(s)
Return True if s is a Python keyword.
keyword.kwlist
Sequence containing all the keywords defined for the interpreter. If any keywords are defined t... | python.library.keyword |
keyword.iskeyword(s)
Return True if s is a Python keyword. | python.library.keyword#keyword.iskeyword |
keyword.issoftkeyword(s)
Return True if s is a Python soft keyword. New in version 3.9. | python.library.keyword#keyword.issoftkeyword |
keyword.kwlist
Sequence containing all the keywords defined for the interpreter. If any keywords are defined to only be active when particular __future__ statements are in effect, these will be included as well. | python.library.keyword#keyword.kwlist |
keyword.softkwlist
Sequence containing all the soft keywords defined for the interpreter. If any soft keywords are defined to only be active when particular __future__ statements are in effect, these will be included as well. New in version 3.9. | python.library.keyword#keyword.softkwlist |
len(s)
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set). CPython implementation detail: len raises OverflowError on lengths larger than sys.maxsize, such as range(2 ** 100). | python.library.functions#len |
license
Object that when printed, prints the message “Type license() to see the full license text”, and when called, displays the full license text in a pager-like fashion (one screen at a time). | python.library.constants#license |
linecache — Random access to text lines Source code: Lib/linecache.py The linecache module allows one to get any line from a Python source file, while attempting to optimize internally, using a cache, the common case where many lines are read from a single file. This is used by the traceback module to retrieve source l... | python.library.linecache |
linecache.checkcache(filename=None)
Check the cache for validity. Use this function if files in the cache may have changed on disk, and you require the updated version. If filename is omitted, it will check all the entries in the cache. | python.library.linecache#linecache.checkcache |
linecache.clearcache()
Clear the cache. Use this function if you no longer need lines from files previously read using getline(). | python.library.linecache#linecache.clearcache |
linecache.getline(filename, lineno, module_globals=None)
Get line lineno from file named filename. This function will never raise an exception — it will return '' on errors (the terminating newline character will be included for lines that are found). If a file named filename is not found, the function first checks f... | python.library.linecache#linecache.getline |
linecache.lazycache(filename, module_globals)
Capture enough detail about a non-file-based module to permit getting its lines later via getline() even if module_globals is None in the later call. This avoids doing I/O until a line is actually needed, without having to carry the module globals around indefinitely. Ne... | python.library.linecache#linecache.lazycache |
class list([iterable])
Lists may be constructed in several ways: Using a pair of square brackets to denote the empty list: []
Using square brackets, separating items with commas: [a], [a, b, c]
Using a list comprehension: [x for x in iterable]
Using the type constructor: list() or list(iterable)
The constructor... | python.library.stdtypes#list |
class list([iterable])
Rather than being a function, list is actually a mutable sequence type, as documented in Lists and Sequence Types — list, tuple, range. | python.library.functions#list |
sort(*, key=None, reverse=False)
This method sorts the list in place, using only < comparisons between items. Exceptions are not suppressed - if any comparison operations fail, the entire sort operation will fail (and the list will likely be left in a partially modified state). sort() accepts two arguments that can o... | python.library.stdtypes#list.sort |
locale — Internationalization services Source code: Lib/locale.py The locale module opens access to the POSIX locale database and functionality. The POSIX locale mechanism allows programmers to deal with certain cultural issues in an application, without requiring the programmer to know all the specifics of each countr... | python.library.locale |
locale.ALT_DIGITS
Get a representation of up to 100 values used to represent the values 0 to 99. | python.library.locale#locale.ALT_DIGITS |
locale.atof(string)
Converts a string to a floating point number, following the LC_NUMERIC settings. | python.library.locale#locale.atof |
locale.atoi(string)
Converts a string to an integer, following the LC_NUMERIC conventions. | python.library.locale#locale.atoi |
locale.bindtextdomain(domain, dir) | python.library.locale#locale.bindtextdomain |
locale.CHAR_MAX
This is a symbolic constant used for different values returned by localeconv(). | python.library.locale#locale.CHAR_MAX |
locale.CODESET
Get a string with the name of the character encoding used in the selected locale. | python.library.locale#locale.CODESET |
locale.CRNCYSTR
Get the currency symbol, preceded by “-” if the symbol should appear before the value, “+” if the symbol should appear after the value, or “.” if the symbol should replace the radix character. | python.library.locale#locale.CRNCYSTR |
locale.currency(val, symbol=True, grouping=False, international=False)
Formats a number val according to the current LC_MONETARY settings. The returned string includes the currency symbol if symbol is true, which is the default. If grouping is true (which is not the default), grouping is done with the value. If inter... | python.library.locale#locale.currency |
locale.dcgettext(domain, msg, category) | python.library.locale#locale.dcgettext |
locale.delocalize(string)
Converts a string into a normalized number string, following the LC_NUMERIC settings. New in version 3.5. | python.library.locale#locale.delocalize |
locale.dgettext(domain, msg) | python.library.locale#locale.dgettext |
locale.D_FMT
Get a string that can be used as a format string for time.strftime() to represent a date in a locale-specific way. | python.library.locale#locale.D_FMT |
locale.D_T_FMT
Get a string that can be used as a format string for time.strftime() to represent date and time in a locale-specific way. | python.library.locale#locale.D_T_FMT |
locale.ERA
Get a string that represents the era used in the current locale. Most locales do not define this value. An example of a locale which does define this value is the Japanese one. In Japan, the traditional representation of dates includes the name of the era corresponding to the then-emperor’s reign. Normally... | python.library.locale#locale.ERA |
locale.ERA_D_FMT
Get a format string for time.strftime() to represent a date in a locale-specific era-based way. | python.library.locale#locale.ERA_D_FMT |
locale.ERA_D_T_FMT
Get a format string for time.strftime() to represent date and time in a locale-specific era-based way. | python.library.locale#locale.ERA_D_T_FMT |
locale.ERA_T_FMT
Get a format string for time.strftime() to represent a time in a locale-specific era-based way. | python.library.locale#locale.ERA_T_FMT |
exception locale.Error
Exception raised when the locale passed to setlocale() is not recognized. | python.library.locale#locale.Error |
locale.format(format, val, grouping=False, monetary=False)
Please note that this function works like format_string() but will only work for exactly one %char specifier. For example, '%f' and '%.0f' are both valid specifiers, but '%f KiB' is not. For whole format strings, use format_string(). Deprecated since version... | python.library.locale#locale.format |
locale.format_string(format, val, grouping=False, monetary=False)
Formats a number val according to the current LC_NUMERIC setting. The format follows the conventions of the % operator. For floating point values, the decimal point is modified if appropriate. If grouping is true, also takes the grouping into account. ... | python.library.locale#locale.format_string |
locale.getdefaultlocale([envvars])
Tries to determine the default locale settings and returns them as a tuple of the form (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, '') runs using the portable 'C' locale. Calling setlocale(LC_ALL, '') lets it use the default locale... | python.library.locale#locale.getdefaultlocale |
locale.getlocale(category=LC_CTYPE)
Returns the current setting for the given locale category as sequence containing language code, encoding. category may be one of the LC_* values except LC_ALL. It defaults to LC_CTYPE. Except for the code 'C', the language code corresponds to RFC 1766. language code and encoding ma... | python.library.locale#locale.getlocale |
locale.getpreferredencoding(do_setlocale=True)
Return the encoding used for text data, according to user preferences. User preferences are expressed differently on different systems, and might not be available programmatically on some systems, so this function only returns a guess. On some systems, it is necessary to... | python.library.locale#locale.getpreferredencoding |
locale.gettext(msg) | python.library.locale#locale.gettext |
locale.LC_ALL
Combination of all locale settings. If this flag is used when the locale is changed, setting the locale for all categories is attempted. If that fails for any category, no category is changed at all. When the locale is retrieved using this flag, a string indicating the setting for all categories is retu... | python.library.locale#locale.LC_ALL |
locale.LC_COLLATE
Locale category for sorting strings. The functions strcoll() and strxfrm() of the locale module are affected. | python.library.locale#locale.LC_COLLATE |
locale.LC_CTYPE
Locale category for the character type functions. Depending on the settings of this category, the functions of module string dealing with case change their behaviour. | python.library.locale#locale.LC_CTYPE |
locale.LC_MESSAGES
Locale category for message display. Python currently does not support application specific locale-aware messages. Messages displayed by the operating system, like those returned by os.strerror() might be affected by this category. | python.library.locale#locale.LC_MESSAGES |
locale.LC_MONETARY
Locale category for formatting of monetary values. The available options are available from the localeconv() function. | python.library.locale#locale.LC_MONETARY |
locale.LC_NUMERIC
Locale category for formatting numbers. The functions format(), atoi(), atof() and str() of the locale module are affected by that category. All other numeric formatting operations are not affected. | python.library.locale#locale.LC_NUMERIC |
locale.LC_TIME
Locale category for the formatting of time. The function time.strftime() follows these conventions. | python.library.locale#locale.LC_TIME |
locale.localeconv()
Returns the database of the local conventions as a dictionary. This dictionary has the following strings as keys:
Category Key Meaning
LC_NUMERIC 'decimal_point' Decimal point character.
'grouping' Sequence of numbers specifying which relative positions the 'thousands_sep' is expected. If... | python.library.locale#locale.localeconv |
locale.nl_langinfo(option)
Return some locale-specific information as a string. This function is not available on all systems, and the set of possible options might also vary across platforms. The possible argument values are numbers, for which symbolic constants are available in the locale module. The nl_langinfo() ... | python.library.locale#locale.nl_langinfo |
locale.NOEXPR
Get a regular expression that can be used with the regex(3) function to recognize a negative response to a yes/no question. | python.library.locale#locale.NOEXPR |
locale.normalize(localename)
Returns a normalized locale code for the given locale name. The returned locale code is formatted for use with setlocale(). If normalization fails, the original name is returned unchanged. If the given encoding is not known, the function defaults to the default encoding for the locale cod... | python.library.locale#locale.normalize |
locale.RADIXCHAR
Get the radix character (decimal dot, decimal comma, etc.). | python.library.locale#locale.RADIXCHAR |
locale.resetlocale(category=LC_ALL)
Sets the locale for category to the default setting. The default setting is determined by calling getdefaultlocale(). category defaults to LC_ALL. | python.library.locale#locale.resetlocale |
locale.setlocale(category, locale=None)
If locale is given and not None, setlocale() modifies the locale setting for the category. The available categories are listed in the data description below. locale may be a string, or an iterable of two strings (language code and encoding). If it’s an iterable, it’s converted ... | python.library.locale#locale.setlocale |
locale.str(float)
Formats a floating point number using the same format as the built-in function str(float), but takes the decimal point into account. | python.library.locale#locale.str |
locale.strcoll(string1, string2)
Compares two strings according to the current LC_COLLATE setting. As any other compare function, returns a negative, or a positive value, or 0, depending on whether string1 collates before or after string2 or is equal to it. | python.library.locale#locale.strcoll |
locale.strxfrm(string)
Transforms a string to one that can be used in locale-aware comparisons. For example, strxfrm(s1) < strxfrm(s2) is equivalent to strcoll(s1, s2) < 0. This function can be used when the same string is compared repeatedly, e.g. when collating a sequence of strings. | python.library.locale#locale.strxfrm |
locale.textdomain(domain) | python.library.locale#locale.textdomain |
locale.THOUSEP
Get the separator character for thousands (groups of three digits). | python.library.locale#locale.THOUSEP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.