chunk_id
large_stringlengths
36
36
doc_type
large_stringclasses
2 values
category
large_stringclasses
17 values
document
large_stringclasses
50 values
version_raw
large_stringclasses
590 values
chunk_index
int64
0
262
text
large_stringlengths
11
5.69k
file_path
large_stringclasses
882 values
91d82e2e-617d-54a2-b928-ace58585d08b
docs
python
python_stdtypes
312
216
The limit is applied to the number of digit characters in the input or output string when a non-linear conversion algorithm would be involved. Underscores and the sign are not counted towards the limit. When an operation would exceed the limit, a [`ValueError`](exceptions.html#ValueError "ValueError") is raised: ```N...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
8cb886fd-e5dd-595c-a09d-e6e519da521e
docs
python
python_stdtypes
312
217
The default limit is 4300 digits as provided in [`sys.int_info.default_max_str_digits`](sys.html#sys.int_info "sys.int_info"). The lowest limit that can be configured is 640 digits as provided in [`sys.int_info.str_digits_check_threshold`](sys.html#sys.int_info "sys.int_info"). Verification: ```None >>> import sys >>...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
8b2ba17b-cf65-5462-bb10-666711483a2d
docs
python
python_stdtypes
312
218
* `str(integer)`. * `repr(integer)`. * any other string conversion to base 10, for example `f"{integer}"`, `"{}".format(integer)`, or `b"%d" % integer`. The limitations do not apply to functions with a linear algorithm: * `int(string, base)` with base 2, 4, 8, 16, or 32. * [`int.from_bytes()`](#int.from_bytes "int....
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
05713a00-b748-57ee-a23c-52727b1f924a
docs
python
python_stdtypes
312
219
* [`PYTHONINTMAXSTRDIGITS`](../using/cmdline.html#envvar-PYTHONINTMAXSTRDIGITS), e.g. `PYTHONINTMAXSTRDIGITS=640 python3` to set the limit to 640 or `PYTHONINTMAXSTRDIGITS=0 python3` to disable the limitation. * [`-X int_max_str_digits`](../using/cmdline.html#cmdoption-X), e.g. `python3 -X int_max_str_digits=640`...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
84f85295-17cd-56ef-adf7-e1dca73d3989
docs
python
python_stdtypes
312
220
[`sys`](sys.html#module-sys "sys: Access system-specific parameters and functions.") APIs: * [`sys.get_int_max_str_digits()`](sys.html#sys.get_int_max_str_digits "sys.get_int_max_str_digits") and [`sys.set_int_max_str_digits()`](sys.html#sys.set_int_max_str_digits "sys.set_int_max_str_digits") are a getter and sette...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
beb7321a-aafb-5cf2-a120-8ed53ec16d2f
docs
python
python_stdtypes
312
221
minimum threshold. A consequence of setting the limit is that Python source code containing decimal integer literals longer than the limit will encounter an error during parsing, usually at startup time or import time or even at installation time - anytime an up to date `.pyc` does not already exist for the code. A wor...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
db9d0f2b-cef8-5b26-a19e-e69bb6831b51
docs
python
python_stdtypes
312
222
reasonable for most applications. If your application requires a different limit, set it from your main entry point using Python version agnostic code as these APIs were added in security patch releases in versions before 3.12. Example: ```None >>> import sys >>> if hasattr(sys, "set_int_max_str_digits"): ... upp...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
552fd162-32fd-5f4e-84cd-a18a50e62bf9
docs
python
python_stdtypes
312
223
They must have since the parser can’t tell the type of the operands. [4] ([1](#id6),[2](#id7),[3](#id8),[4](#id9)) Cased characters are those with general category property being one of “Lu” (Letter, uppercase), “Ll” (Letter, lowercase), or “Lt” (Letter, titlecase). [5] ([1](#id10),[2](#id11)) To format only a tu...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
9a6139bc-630a-56f7-97fe-cb36eaf576fc
docs
python
python_stdtypes
313
0
# Built-in Types¶ Source: https://docs.python.org/3.13/library/stdtypes.html Version: 3.13 The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some collection classes are mutable. T...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b8ca9aec-5402-5c3a-b975-240a4ed274b1
docs
python
python_stdtypes
313
1
## Truth Value Testing[¶](#truth-value-testing "Link to this heading") Any object can be tested for truth value, for use in an [`if`](../reference/compound_stmts.html#if) or [`while`](../reference/compound_stmts.html#while) condition or as operand of the Boolean operations below. By default, an object is considered t...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8627f975-408a-5280-b8e3-e5f0766d24ad
docs
python
python_stdtypes
313
2
or `False` for false and `1` or `True` for true, unless otherwise stated. (Important exception: the Boolean operations `or` and `and` always return one of their operands.) ## Boolean Operations — `and`, `or`, `not`[¶](#boolean-operations-and-or-not "Link to this heading") These are the Boolean operations, ordered by ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
9b902d82-8a4a-524f-ba11-6997d88d042c
docs
python
python_stdtypes
313
3
## Comparisons[¶](#comparisons "Link to this heading") There are eight comparison operations in Python. They all have the same priority (which is higher than that of the Boolean operations). Comparisons can be chained arbitrarily; for example, `x < y <= z` is equivalent to `x < y and y <= z`, except that *y* is evalua...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3e0f8bd2-70cd-59ed-b233-fdbdb799cc53
docs
python
python_stdtypes
313
4
operators are only defined where they make sense; for example, they raise a [`TypeError`](exceptions.html#TypeError "TypeError") exception when one of the arguments is a complex number. Non-identical instances of a class normally compare as non-equal unless the class defines the [`__eq__()`](../reference/datamodel.htm...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
af0636d8-5d2c-5c6a-91cc-ad99aaed5267
docs
python
python_stdtypes
313
5
[`__eq__()`](../reference/datamodel.html#object.__eq__ "object.__eq__") are sufficient, if you want the conventional meanings of the comparison operators). The behavior of the [`is`](../reference/expressions.html#is) and [`is not`](../reference/expressions.html#is-not) operators cannot be customized; also they can be ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
d3927069-0ec4-56ff-a3bd-f06a4811d4b3
docs
python
python_stdtypes
313
6
numbers*, and *complex numbers*. In addition, Booleans are a subtype of integers. Integers have unlimited precision. Floating-point numbers are usually implemented using double in C; information about the precision and internal representation of floating-point numbers for the machine on which your program is running is...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
344a7ee8-eccb-50d9-9332-16210e05d333
docs
python
python_stdtypes
313
7
numbers) yield integers. Numeric literals containing a decimal point or an exponent sign yield floating-point numbers. Appending `'j'` or `'J'` to a numeric literal yields an imaginary number (a complex number with a zero real part) which you can add to an integer or float to get a complex number with real and imaginar...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e7d70cba-a6b4-5821-859d-ea7414372c0b
docs
python
python_stdtypes
313
8
the operations, see [Operator precedence](../reference/expressions.html#operator-summary)): | Operation | Result | Notes | Full documentation | | --- | --- | --- | --- | | `x + y` | sum of *x* and *y* | | | | `x - y` | difference of *x* and *y* | | | | `x * y` | product of *x* and *y* | | | | `x / y` | quotient ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
bca02218-5181-50d1-9285-5940b95d7a25
docs
python
python_stdtypes
313
9
| `divmod(x, y)` | the pair `(x // y, x % y)` | (2) | [`divmod()`](functions.html#divmod "divmod") | | `pow(x, y)` | *x* to the power *y* | (5) | [`pow()`](functions.html#pow "pow") | | `x ** y` | *x* to the power *y* | (5) | | Notes: 1. Also referred to as integer division. For operands of type [`int`](functions.ht...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
a4d1e85d-58e2-5c09-b36b-4fe9f92f5807
docs
python
python_stdtypes
313
10
fractional part. See functions [`math.floor()`](math.html#math.floor "math.floor") and [`math.ceil()`](math.html#math.ceil "math.ceil") for alternative conversions. 4. float also accepts the strings “nan” and “inf” with an optional prefix “+” or “-” for Not a Number (NaN) and positive or negative infinity. 5. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
147ed3f4-6a30-5108-a0bd-488b1b602c2c
docs
python
python_stdtypes
313
11
| [`math.trunc(x)`](math.html#math.trunc "math.trunc") | *x* truncated to [`Integral`](numbers.html#numbers.Integral "numbers.Integral") | | [`round(x[, n])`](functions.html#round "round") | *x* rounded to *n* digits, rounding half to even. If *n* is omitted, it defaults to 0. | | [`math.floor(x)`](math.html#math.floor...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b4c34cd5-ed98-5354-890c-b4252eb97795
docs
python
python_stdtypes
313
12
operations is calculated as though carried out in two’s complement with an infinite number of sign bits. The priorities of the binary bitwise operations are all lower than the numeric operations and higher than the comparisons; the unary operation `~` has the same priority as the other unary numeric operations (`+` an...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
63a7651d-44ac-5ebf-8a64-937f97cd6fcc
docs
python
python_stdtypes
313
13
3. A right shift by *n* bits is equivalent to floor division by `pow(2, n)`. 4. Performing these calculations with at least one extra sign extension bit in a finite two’s complement representation (a working bit-width of `1 + max(x.bit_length(), y.bit_length())` or more) is sufficient to get the same result as...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
1d6de42d-9ba1-5893-a2cb-3649af15cfa7
docs
python
python_stdtypes
313
14
More precisely, if `x` is nonzero, then `x.bit_length()` is the unique positive integer `k` such that `2**(k-1) <= abs(x) < 2**k`. Equivalently, when `abs(x)` is small enough to have a correctly rounded logarithm, then `k = 1 + int(log(abs(x), 2))`. If `x` is zero, then `x.bit_length()` returns `0`....
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e769dc94-2643-5e12-8baa-545a052fd9e0
docs
python
python_stdtypes
313
15
return bin(self).count("1") ``` Added in version 3.10. int.to\_bytes(*length=1*, *byteorder='big'*, *\**, *signed=False*)[¶](#int.to_bytes "Link to this definition") : Return an array of bytes representing an integer. ```None >>> (1024).to_bytes(2, byteorder='big') b'\x04\x00' >>> (...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
a6d6e7f0-555c-5561-8693-ab714b60241a
docs
python
python_stdtypes
313
16
`"big"`, the most significant byte is at the beginning of the byte array. If *byteorder* is `"little"`, the most significant byte is at the end of the byte array. The *signed* argument determines whether two’s complement is used to represent the integer. If *signed* is `False` and a negative intege...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e01a3bc9-e6b7-5046-8df4-04873b0f6c5c
docs
python
python_stdtypes
313
17
order = reversed(range(length)) else: raise ValueError("byteorder must be either 'little' or 'big'") return bytes((n >> i*8) & 0xff for i in order) ``` Added in version 3.2. Changed in version 3.11: Added default argument values for `length` and `byteorder`. *clas...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
7e954c7d-f2b4-5a50-aea4-4deb3d19583e
docs
python
python_stdtypes
313
18
The *byteorder* argument determines the byte order used to represent the integer, and defaults to `"big"`. If *byteorder* is `"big"`, the most significant byte is at the beginning of the byte array. If *byteorder* is `"little"`, the most significant byte is at the end of the byte array. To request t...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8f7642db-86e7-544b-8038-7cea3db0d979
docs
python
python_stdtypes
313
19
if signed and little_ordered and (little_ordered[-1] & 0x80): n -= 1 << 8*len(little_ordered) return n ``` Added in version 3.2. Changed in version 3.11: Added default argument value for `byteorder`. int.as\_integer\_ratio()[¶](#int.as_integer_ratio "Link to this definition")...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8506c40e-63fc-55d0-ab1e-6792cacaed22
docs
python
python_stdtypes
313
20
class](../glossary.html#term-abstract-base-class). float also has the following additional methods. float.as\_integer\_ratio()[¶](#float.as_integer_ratio "Link to this definition") : Return a pair of integers whose ratio is exactly equal to the original float. The ratio is in lowest terms and has a positive deno...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
41937b7d-4fd0-5e7d-87ee-302aa60c62ec
docs
python
python_stdtypes
313
21
contrast, hexadecimal strings allow exact representation and specification of floating-point numbers. This can be useful when debugging, and in numerical work. float.hex()[¶](#float.hex "Link to this definition") : Return a representation of a floating-point number as a hexadecimal string. For finite floating-po...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
745d91fb-6896-5504-a90a-e2744e994e11
docs
python
python_stdtypes
313
22
and `fraction` are strings of hexadecimal digits, and `exponent` is a decimal integer with an optional leading sign. Case is not significant, and there must be at least one hexadecimal digit in either the integer or the fraction. This syntax is similar to the syntax specified in section 6.4.4.2 of the C99 standard, and...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
803196d4-973c-5c61-b34c-a0efd5653790
docs
python
python_stdtypes
313
23
Applying the reverse conversion to `3740.0` gives a different hexadecimal string representing the same number: ```None >>> float.hex(3740.0) '0x1.d380000000000p+11' ``` ### Hashing of numeric types[¶](#hashing-of-numeric-types "Link to this heading") For numbers `x` and `y`, possibly of different types, it’s a requi...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
ce3bc08f-3f52-57b8-bac8-081e5afc439a
docs
python
python_stdtypes
313
24
[`int`](functions.html#int "int") and [`fractions.Fraction`](fractions.html#fractions.Fraction "fractions.Fraction"), and all finite instances of [`float`](functions.html#float "float") and [`decimal.Decimal`](decimal.html#decimal.Decimal "decimal.Decimal"). Essentially, this function is given by reduction modulo `P` f...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
eb1cc588-0e9b-5355-875d-c25936b64308
docs
python
python_stdtypes
313
25
divisible by `P` (but `m` is not) then `n` has no inverse modulo `P` and the rule above doesn’t apply; in this case define `hash(x)` to be the constant value `sys.hash_info.inf`. * If `x = m / n` is a negative rational number define `hash(x)` as `-hash(-x)`. If the resulting hash is `-1`, replace it with `-2`...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3c38c24c-f1fc-59f9-aa17-be816ce9ebd0
docs
python
python_stdtypes
313
26
number, [`float`](functions.html#float "float"), or [`complex`](functions.html#complex "complex"): ```None import sys, math def hash_fraction(m, n): """Compute the hash of a rational number m / n. Assumes m and n are integers, with n positive. Equivalent to hash(fractions.Fraction(m, n)). """ P ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3b3f21c5-57b8-598d-a2f4-b36064883339
docs
python
python_stdtypes
313
27
return sys.hash_info.inf if x > 0 else -sys.hash_info.inf else: return hash_fraction(*x.as_integer_ratio()) def hash_complex(z): """Compute the hash of a complex number z.""" hash_value = hash_float(z.real) + sys.hash_info.imag * hash_float(z.imag) # do a signed reduction modulo 2**sys...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
6f3c31e5-956b-5e36-8562-36654fe48263
docs
python
python_stdtypes
313
28
`or` and `not`. When applying the bitwise operators `&`, `|`, `^` to two booleans, they return a bool equivalent to the logical operations “and”, “or”, “xor”. However, the logical operators `and`, `or` and `!=` should be preferred over `&`, `|` and `^`. Deprecated since version 3.12: The use of the bitwise inversion o...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
03d3e251-b0e4-5472-a1c3-8e3428777c8e
docs
python
python_stdtypes
313
29
support iteration. Sequences, described below in more detail, always support the iteration methods. One method needs to be defined for container objects to provide [iterable](../glossary.html#term-iterable) support: container.\_\_iter\_\_()[¶](#container.__iter__ "Link to this definition") : Return an [iterator](.....
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e0d6fc9d-f263-58f8-9b7f-0f4884d7d790
docs
python
python_stdtypes
313
30
methods, which together form the *iterator protocol*: iterator.\_\_iter\_\_()[¶](#iterator.__iter__ "Link to this definition") : Return the [iterator](../glossary.html#term-iterator) object itself. This is required to allow both containers and iterators to be used with the [`for`](../reference/compound_stmts.htm...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e16f93ed-1c6d-5f85-a082-9bbbdf821237
docs
python
python_stdtypes
313
31
Python objects in the Python/C API. Python defines several iterator objects to support iteration over general and specific sequence types, dictionaries, and other more specialized forms. The specific types are not important beyond their implementation of the iterator protocol. Once an iterator’s [`__next__()`](#i...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8e0d1c97-a15b-50fb-8ff7-2b4deaa85618
docs
python
python_stdtypes
313
32
generator object) supplying the [`__iter__()`](#iterator.__iter__ "iterator.__iter__") and [`__next__()`](../reference/expressions.html#generator.__next__ "generator.__next__") methods. More information about generators can be found in [the documentation for the yield expression](../reference/expressions.html#yieldexpr...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e71f7400-a3c7-59b7-a160-ab8adf5deb1c
docs
python
python_stdtypes
313
33
provided to make it easier to correctly implement these operations on custom sequence types. This table lists the sequence operations sorted in ascending priority. In the table, *s* and *t* are sequences of the same type, *n*, *i*, *j* and *k* are integers and *x* is an arbitrary object that meets any type and value r...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
1846f210-cbe8-5d36-b5cd-9906054cf5a9
docs
python
python_stdtypes
313
34
| `s[i:j:k]` | slice of *s* from *i* to *j* with step *k* | (3)(5) | | `len(s)` | length of *s* | | | `min(s)` | smallest item of *s* | | | `max(s)` | largest item of *s* | | Sequences of the same type also support comparisons. In particular, tuples and lists are compared lexicographically by comparing correspondin...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
4857b061-f06f-50b9-8f25-5b6cb2d43bb4
docs
python
python_stdtypes
313
35
1. While the `in` and `not in` operations are used only for simple containment testing in the general case, some specialised sequences (such as [`str`](#str "str"), [`bytes`](#bytes "bytes") and [`bytearray`](#bytearray "bytearray")) also use them for subsequence testing: ```None >>> "gg" in "eggs" T...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
9a8acbc0-5b2a-5bd9-8595-802a2e57a118
docs
python
python_stdtypes
313
36
>>> lists = [[] for i in range(3)] >>> lists[0].append(3) >>> lists[1].append(5) >>> lists[2].append(7) >>> lists [[3], [5], [7]] ``` Further explanation is available in the FAQ entry [How do I create a multidimensional list?](../faq/programming.html#faq-multidimensional-list). 3. If *i* or ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e2b18c28-4e61-557e-8f1e-98815295fc90
docs
python
python_stdtypes
313
37
the indices are `i`, `i+k`, `i+2*k`, `i+3*k` and so on, stopping when *j* is reached (but never including *j*). When *k* is positive, *i* and *j* are reduced to `len(s)` if they are greater. When *k* is negative, *i* and *j* are reduced to `len(s) - 1` if they are greater. If *i* or *j* are omitted or `N...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8f48fc70-78d6-506c-be1b-0ea54c513619
docs
python
python_stdtypes
313
38
* if concatenating [`bytes`](#bytes "bytes") objects, you can similarly use [`bytes.join()`](#bytes.join "bytes.join") or [`io.BytesIO`](io.html#io.BytesIO "io.BytesIO"), or you can do in-place concatenation with a [`bytearray`](#bytearray "bytearray") object. [`bytearray`](#bytearray "bytearray") obj...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
bdeacbed-9c84-5078-9f93-8e5b15de4af3
docs
python
python_stdtypes
313
39
: Return the total number of occurrences of *value* in *sequence*. sequence.index(*value[, start[, stop]*)[¶](#sequence.index "Link to this definition") : Return the index of the first occurrence of *value* in *sequence*. Raises [`ValueError`](exceptions.html#ValueError "ValueError") if *value* is not found i...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
c1d8275c-98a7-51b6-acf1-5b20ce189133
docs
python
python_stdtypes
313
40
This support allows immutable sequences, such as [`tuple`](#tuple "tuple") instances, to be used as [`dict`](#dict "dict") keys and stored in [`set`](#set "set") and [`frozenset`](#frozenset "frozenset") instances. Attempting to hash an immutable sequence that contains unhashable values will result in [`TypeError`](ex...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
aabee6a5-aa0f-5cb6-bf9d-7ec13d56303f
docs
python
python_stdtypes
313
41
accepts integers that meet the value restriction `0 <= x <= 255`). | Operation | Result | Notes | | --- | --- | --- | | `s[i] = x` | item *i* of *s* is replaced by *x* | | | `del s[i]` | removes item *i* of *s* | | | `s[i:j] = t` | slice of *s* from *i* to *j* is replaced by the contents of the iterable *t* | | | `...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
ebf433d8-06f9-5864-b323-3e976cb96e69
docs
python
python_stdtypes
313
42
[`__index__()`](../reference/datamodel.html#object.__index__ "object.__index__"). Zero and negative values of *n* clear the sequence. Items in the sequence are not copied; they are referenced multiple times, as explained for `s * n` under [Common Sequence Operations](#typesseq-common). Mutable Sequence Method...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
08d9acf4-567b-5b85-9a4e-8edc0bf1553e
docs
python
python_stdtypes
313
43
[`MutableSequence`](collections.abc.html#collections.abc.MutableSequence "collections.abc.MutableSequence") [`ABC`](abc.html#abc.ABC "abc.ABC"), but most concrete mutable sequence types provide it. sequence.extend(*iterable*, */*)[¶](#sequence.extend "Link to this definition") : Extend *sequence* with the co...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
0050c375-dd0e-5fc3-b0fb-2ae50c29bff5
docs
python
python_stdtypes
313
44
Raises [`ValueError`](exceptions.html#ValueError "ValueError") if *value* is not found in *sequence*. sequence.reverse()[¶](#sequence.reverse "Link to this definition") : Reverse the items of *sequence* in place. This method maintains economy of space when reversing a large sequence. To remind users that...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
1fc63f5b-3d69-562f-a7f3-9d442699ed39
docs
python
python_stdtypes
313
45
The constructor builds a list whose items are the same and in the same order as *iterable*’s items. *iterable* may be either a sequence, a container that supports iteration, or an iterator object. If *iterable* is already a list, a copy is made and returned, similar to `iterable[:]`. For example, `l...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
02866784-5b89-5e35-a7ce-c1e9b7984389
docs
python
python_stdtypes
313
46
fail, the entire sort operation will fail (and the list will likely be left in a partially modified state). [`sort()`](#list.sort "list.sort") accepts two arguments that can only be passed by keyword ([keyword-only arguments](../glossary.html#keyword-only-parameter)): *key* spe...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
9079bda9-e8c4-56b2-ab72-f71a9910f623
docs
python
python_stdtypes
313
47
are sorted as if each comparison were reversed. This method modifies the sequence in place for economy of space when sorting a large sequence. To remind users that it operates by side effect, it does not return the sorted sequence (use [`sorted()`](functions.html#sorted "sorted") to ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
9e657e3f-5b3d-53f2-a357-44a4a214bf5a
docs
python
python_stdtypes
313
48
list appear empty for the duration, and raises [`ValueError`](exceptions.html#ValueError "ValueError") if it can detect that the list has been mutated during a sort. ### Tuples[¶](#tuples "Link to this heading") Tuples are immutable sequences, typically used to store collections of heterogeneous data ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e95b5768-c080-569e-b1b4-3d1799d59c07
docs
python
python_stdtypes
313
49
The constructor builds a tuple whose items are the same and in the same order as *iterable*’s items. *iterable* may be either a sequence, a container that supports iteration, or an iterator object. If *iterable* is already a tuple, it is returned unchanged. For example, `tuple('abc')` returns `('a',...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
acd0e8f1-4e91-5e1d-9c02-4ef4d48f1a04
docs
python
python_stdtypes
313
50
access by index, [`collections.namedtuple()`](collections.html#collections.namedtuple "collections.namedtuple") may be a more appropriate choice than a simple tuple object. ### Ranges[¶](#ranges "Link to this heading") The [`range`](#range "range") type represents an immutable sequence of numbers and is commonly used...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
a8ddf722-068e-54bc-b385-7834367ff64c
docs
python
python_stdtypes
313
51
For a positive *step*, the contents of a range `r` are determined by the formula `r[i] = start + step*i` where `i >= 0` and `r[i] < stop`. For a negative *step*, the contents of the range are still determined by the formula `r[i] = start + step*i`, but the constraints are `i >= 0` and `r[i] > s...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
2cf88cc6-33f2-5588-bd69-fe42e234fe3a
docs
python
python_stdtypes
313
52
[0, 5, 10, 15, 20, 25] >>> list(range(0, 10, 3)) [0, 3, 6, 9] >>> list(range(0, -10, -1)) [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] >>> list(range(0)) [] >>> list(range(1, 0)) [] ``` Ranges implement all of the [common](#typesseq-common) sequence operations except concaten...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
d549373d-4b1b-5d0f-a223-6d5201a68099
docs
python
python_stdtypes
313
53
[`tuple`](#tuple "tuple") is that a [`range`](#range "range") object will always take the same (small) amount of memory, no matter the size of the range it represents (as it only stores the `start`, `stop` and `step` values, calculating individual items and subranges as needed). Range objects implement the [`collectio...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
2e240e91-39e3-52f4-b156-20547ebc57cd
docs
python
python_stdtypes
313
54
objects that compare equal might have different [`start`](#range.start "range.start"), [`stop`](#range.stop "range.stop") and [`step`](#range.step "range.step") attributes, for example `range(0) == range(2, 1, 3)` or `range(0, 3, 2) == range(0, 4, 2)`.) Changed in version 3.2: Implement the Sequence ABC. Support slici...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
77ae3cf7-756b-5f2d-b663-f06d04807150
docs
python
python_stdtypes
313
55
## Text Sequence Type — [`str`](#str "str")[¶](#text-sequence-type-str "Link to this heading") Textual data in Python is handled with [`str`](#str "str") objects, or *strings*. Strings are immutable [sequences](#typesseq) of Unicode code points. String literals are written in a variety of ways: * Single quotes: `'all...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
5eaddaae-fb35-5823-803a-a2a947afb967
docs
python
python_stdtypes
313
56
including supported [escape sequences](../reference/lexical_analysis.html#escape-sequences), and the `r` (“raw”) prefix that disables most escape sequence processing. Strings may also be created from other objects using the [`str`](#str "str") constructor. Since there is no separate “character” type, indexing a strin...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f344f578-1256-525b-817e-c6a94e24dbae
docs
python
python_stdtypes
313
57
*class* str(*object*, *\**, *errors*) : Return a [string](#textseq) version of *object*. If *object* is not provided, returns the empty string. Otherwise, the behavior of `str()` depends on whether *encoding* or *errors* is given, as follows. If neither *encoding* nor *errors* is given, `str(object)` ret...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
894163a4-ccae-503a-910a-883a8f2acacd
docs
python
python_stdtypes
313
58
this case, if *object* is a [`bytes`](#bytes "bytes") (or [`bytearray`](#bytearray "bytearray")) object, then `str(bytes, encoding, errors)` is equivalent to [`bytes.decode(encoding, errors)`](#bytes.decode "bytes.decode"). Otherwise, the bytes object underlying the buffer object is obtained before call...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
71746b4c-59b0-56da-91ba-85614a655a7b
docs
python
python_stdtypes
313
59
[Text Sequence Type — str](#textseq) and the [String Methods](#string-methods) section below. To output formatted strings, see the [f-strings](../reference/lexical_analysis.html#f-strings) and [Format String Syntax](string.html#formatstrings) sections. In addition, see the [Text Processing Services](text.ht...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
fae4826c-3f0b-5349-84d2-ba074e61332e
docs
python
python_stdtypes
313
60
handle ([printf-style String Formatting](#old-string-formatting)). The [Text Processing Services](text.html#textservices) section of the standard library covers a number of other modules that provide various text related utilities (including regular expression support in the [`re`](re.html#module-re "re: Regular expre...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3f8b0975-1150-5ce3-ab62-606c66c06a02
docs
python
python_stdtypes
313
61
intended to remove all case distinctions in a string. For example, the German lowercase letter `'ß'` is equivalent to `"ss"`. Since it is already lowercase, [`lower()`](#str.lower "str.lower") would do nothing to `'ß'`; [`casefold()`](#str.casefold "str.casefold") converts it to `"ss"`. For example:...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f3e59f30-dc0c-5e45-8cb2-e069c8951c26
docs
python
python_stdtypes
313
62
'--Python--' >>> 'Python'.center(4) 'Python' ``` str.count(*sub*[, *start*[, *end*]])[¶](#str.count "Link to this definition") : Return the number of non-overlapping occurrences of substring *sub* in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
1709d82a-ea5d-5320-b5b8-d391ddcd1661
docs
python
python_stdtypes
313
63
*errors* controls how encoding errors are handled. If `'strict'` (the default), a [`UnicodeError`](exceptions.html#UnicodeError "UnicodeError") exception is raised. Other possible values are `'ignore'`, `'replace'`, `'xmlcharrefreplace'`, `'backslashreplace'` and any other name registered via [`code...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
eadef519-9b5b-58f5-b197-395ca5a4bc44
docs
python
python_stdtypes
313
64
Changed in version 3.9: The value of the *errors* argument is now checked in [Python Development Mode](devmode.html#devmode) and in [debug mode](../using/configure.html#debug-build). str.endswith(*suffix*[, *start*[, *end*]])[¶](#str.endswith "Link to this definition") : Return `True` if the string ends with...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
128f15f8-763d-57f9-bf2a-d7fe11224c0f
docs
python
python_stdtypes
313
65
str.expandtabs(*tabsize=8*)[¶](#str.expandtabs "Link to this definition") : Return a copy of the string where all tab characters are replaced by one or more spaces, depending on the current column and the given tab size. Tab positions occur every *tabsize* characters (default is 8, giving tab positions at...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
119ed727-3287-5f48-b66a-d9196cdf3f7b
docs
python
python_stdtypes
313
66
'01 012 0123 01234' >>> '01\t012\t0123\t01234'.expandtabs(4) '01 012 0123 01234' >>> print('01\t012\n0123\t01234'.expandtabs(4)) 01 012 0123 01234 ``` str.find(*sub*[, *start*[, *end*]])[¶](#str.find "Link to this definition") : Return the lowest index in the string wh...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
082b7b1d-6310-552e-ae64-4351e65236f4
docs
python
python_stdtypes
313
67
str.format(*\*args*, *\*\*kwargs*)[¶](#str.format "Link to this definition") : Perform a string formatting operation. The string on which this method is called can contain literal text or replacement fields delimited by braces `{}`. Each replacement field contains either the numeric index of a positional ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3b6a98c5-c640-593d-b8cc-e2e1657cd834
docs
python
python_stdtypes
313
68
When formatting a number ([`int`](functions.html#int "int"), [`float`](functions.html#float "float"), [`complex`](functions.html#complex "complex"), [`decimal.Decimal`](decimal.html#decimal.Decimal "decimal.Decimal") and subclasses) with the `n` type (ex: `'{:n}'.format(1234)`), the function temporarily set...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f0717193-484e-5ddb-ab2d-e577f253317e
docs
python
python_stdtypes
313
69
if for example `mapping` is a dict subclass: ```None >>> class Default(dict): ... def __missing__(self, key): ... return key ... >>> '{name} was born in {country}'.format_map(Default(name='Guido')) 'Guido was born in country' ``` Added in version 3.2. str.index(*su...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
cd924ddc-824c-5016-9471-aed68acbf0d7
docs
python
python_stdtypes
313
70
: Return `True` if all characters in the string are alphanumeric and there is at least one character, `False` otherwise. A character `c` is alphanumeric if one of the following returns `True`: `c.isalpha()`, `c.isdecimal()`, `c.isdigit()`, or `c.isnumeric()`. str.isalpha()[¶](#str.isalpha "Link to this d...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
a42a1bbf-86a4-5bb9-84c3-dc8398ccf623
docs
python
python_stdtypes
313
71
>>> 'µ'.isalpha() # non-ASCII characters can be considered alphabetical too True ``` See [Unicode Properties](../howto/unicode.html#unicode-properties). str.isascii()[¶](#str.isascii "Link to this definition") : Return `True` if the string is empty or all characters in the string are ASCII, `Fa...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
a20d1a96-3c6d-55c0-bb8d-420b94d04858
docs
python
python_stdtypes
313
72
>>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() # Arabic-Indic digits zero to nine True >>> 'alphabetic'.isdecimal() False ``` str.isdigit()[¶](#str.isdigit "Link to this definition") : Return `True` if all characters in the string are digits and there is at least one character, `False` otherwise. Digits inclu...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
15b7ca12-0eb2-5810-bef8-3f7554304389
docs
python
python_stdtypes
313
73
[`keyword.iskeyword()`](keyword.html#keyword.iskeyword "keyword.iskeyword") can be used to test whether string `s` is a reserved identifier, such as [`def`](../reference/compound_stmts.html#def) and [`class`](../reference/compound_stmts.html#class). Example: ```None >>> from keyword import iskeywo...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
26b60b43-13f8-523c-95ad-5f8da3eae4e5
docs
python
python_stdtypes
313
74
VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property value Numeric\_Type=Digit, Numeric\_Type=Decimal or Numeric\_Type=Numeric. For example: ```None >>> '0123456789'.isnumeric() True >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # Arabic-indic digit zero to nine True ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8062c0bb-49ea-53c0-b18e-cdbae783daa2
docs
python
python_stdtypes
313
75
its output; “non-printable” means that [`repr()`](functions.html#repr "repr") on built-in types will hex-escape the character. It has no bearing on the handling of strings written to [`sys.stdout`](sys.html#sys.stdout "sys.stdout") or [`sys.stderr`](sys.html#sys.stderr "sys.stderr"). The printable char...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
2df14a1b-e0e6-5075-84cb-863c956366cb
docs
python
python_stdtypes
313
76
: Return `True` if there are only whitespace characters in the string and there is at least one character, `False` otherwise. A character is *whitespace* if in the Unicode character database (see [`unicodedata`](unicodedata.html#module-unicodedata "unicodedata: Access the Unicode Database.")), either its...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
1fc1f996-f297-5441-af16-4334573f143e
docs
python
python_stdtypes
313
77
: Return `True` if all cased characters [[4]](#id15) in the string are uppercase and there is at least one cased character, `False` otherwise. ```None >>> 'BANANA'.isupper() True >>> 'banana'.isupper() False >>> 'baNana'.isupper() False >>> ' '.isupper() False ``` str.joi...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
dda86e1b-b95e-55b0-a2d1-5e3ef1f3d9c6
docs
python
python_stdtypes
313
78
: Return the string left justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`. For example: ```None >>> 'Python'.ljust(10) 'Python ' >>> 'Python...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
71370caa-be66-53db-a103-32fcc97e60c5
docs
python
python_stdtypes
313
79
: Return a copy of the string with leading characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or `None`, the *chars* argument defaults to removing whitespace. The *chars* argument is not a prefix; rather, all combinations of its values are strip...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
905da03c-a5ae-50df-aca0-87d53fcd2581
docs
python
python_stdtypes
313
80
: This static method returns a translation table usable for [`str.translate()`](#str.translate "str.translate"). If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters (strings of length 1) to Unicode ordinals, strings (of arbitrary lengths) or `None`. Ch...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
9bb60a87-5a0a-5ba3-8130-59988239ac32
docs
python
python_stdtypes
313
81
the string itself, followed by two empty strings. str.removeprefix(*prefix*, */*)[¶](#str.removeprefix "Link to this definition") : If the string starts with the *prefix* string, return `string[len(prefix):]`. Otherwise, return a copy of the original string: ```None >>> 'TestHook'.removeprefix('...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
0f7cc639-63cd-55da-ae24-ad82f3d24b28
docs
python
python_stdtypes
313
82
See also [`removeprefix()`](#str.removeprefix "str.removeprefix") and [`endswith()`](#str.endswith "str.endswith"). str.replace(*old*, *new*, */*, *count=-1*)[¶](#str.replace "Link to this definition") : Return a copy of the string with all occurrences of substring *old* replaced by *new*. If *count* is give...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
083c0bb5-cd36-5b8e-8197-ba569b99de21
docs
python
python_stdtypes
313
83
and *end* are interpreted as in slice notation. Return `-1` on failure. For example: ```None >>> 'spam, spam, spam'.rfind('sp') 12 >>> 'spam, spam, spam'.rfind('sp', 0, 10) 6 ``` See also [`find()`](#str.find "str.find") and [`rindex()`](#str.rindex "str.rindex"). str.rindex(*sub*...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b9ba09cb-16e2-5cc3-9ffc-f3f2deff03fb
docs
python
python_stdtypes
313
84
str.rjust(*width*, *fillchar=' '*, */*)[¶](#str.rjust "Link to this definition") : Return the string right justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`. str.rpa...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
300853b8-297f-58cf-8cba-300dcae302d1
docs
python
python_stdtypes
313
85
str.rsplit(*sep=None*, *maxsplit=-1*)[¶](#str.rsplit "Link to this definition") : Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done, the *rightmost* ones. If *sep* is not specified or `None`, any whitespace string is a ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
36eee3af-318e-5f9f-9ccd-477d0fca6102
docs
python
python_stdtypes
313
86
See [`str.removesuffix()`](#str.removesuffix "str.removesuffix") for a method that will remove a single suffix string rather than all of a set of characters. For example: ```None >>> 'Monty Python'.rstrip(' Python') 'M' >>> 'Monty Python'.removesuffix(' Python') 'Monty' ``` str.split(*...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
17e9068f-494b-5699-94b6-f53f2b345b72
docs
python
python_stdtypes
313
87
[`re.split()`](re.html#re.split "re.split")). Splitting an empty string with a specified separator returns `['']`. For example: ```None >>> '1,2,3'.split(',') ['1', '2', '3'] >>> '1,2,3'.split(',', maxsplit=1) ['1', '2,3'] >>> '1,2,,3,'.split(',') ['1', '2', '', '3', ''] >>...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
0c5b58fb-9cac-5103-89a6-bf2040dd5841
docs
python
python_stdtypes
313
88
If *sep* is not specified or is `None` and *maxsplit* is `0`, only leading runs of consecutive whitespace are considered. For example: ```None >>> "".split(None, 0) [] >>> " ".split(None, 0) [] >>> " foo ".split(maxsplit=0) ['foo '] ``` See also [`join()`](#str...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b2936e5e-c50d-5afb-a6f5-2e7a795f3220
docs
python
python_stdtypes
313
89
| `\x1c` | File Separator | | `\x1d` | Group Separator | | `\x1e` | Record Separator | | `\x85` | Next Line (C1 Control Code) | | `\u2028` | Line Separator | | `\u2029` | Paragraph Separator | Changed in version 3.2: `\v` and `\f` added to list of line boundaries. For example: ```...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
af4e1a62-f96f-5663-a465-7a49116283aa
docs
python
python_stdtypes
313
90
str.startswith(*prefix*[, *start*[, *end*]])[¶](#str.startswith "Link to this definition") : Return `True` if string starts with the *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, sto...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
01dab625-24d3-5ce9-8e34-ec3ae5adcd5c
docs
python
python_stdtypes
313
91
The *chars* argument is not a prefix or suffix; rather, all combinations of its values are stripped: ```None >>> ' spacious '.strip() 'spacious' >>> 'www.example.com'.strip('cmowz.') 'example' ``` The outermost leading and trailing *chars* argument values are stripped from ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md