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
75959784-6408-5156-b564-71f67ac693bc
docs
python
python_stdtypes
312
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_312.md
5323ccd2-a729-5844-9474-bada365436e7
docs
python
python_stdtypes
312
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_312.md
8c208e11-2658-5b20-a826-4cf32e23c995
docs
python
python_stdtypes
312
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_312.md
ccb0ac59-0ace-5390-bfb5-cf03ac5c20a8
docs
python
python_stdtypes
312
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_312.md
4e31acc4-b829-5e85-a4c5-b9a556bb8ffd
docs
python
python_stdtypes
312
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_312.md
8db62b64-92c3-5156-b525-e415ebd2d35a
docs
python
python_stdtypes
312
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_312.md
224f6a15-c4fa-5d47-852f-bdfa8869bf13
docs
python
python_stdtypes
312
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_312.md
0b30b840-7567-5d79-a0ad-d5d7aaffd4dc
docs
python
python_stdtypes
312
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_312.md
e5da4c8f-c10a-5856-8457-6979bf9e43d9
docs
python
python_stdtypes
312
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_312.md
9684377d-1dfe-5300-ac4d-35c1817c4af1
docs
python
python_stdtypes
312
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_312.md
c67c6898-f628-51e2-9d64-97cce11424f2
docs
python
python_stdtypes
312
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_312.md
55d34b8d-bf43-5377-bea4-bdd076b0a507
docs
python
python_stdtypes
312
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_312.md
76cfbeeb-b9ea-55f1-8c9a-278c8a1f2a9d
docs
python
python_stdtypes
312
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_312.md
8b3f91fa-862f-5b68-b83a-b1870976e7c1
docs
python
python_stdtypes
312
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_312.md
cfd8f4df-33b7-5ced-acd1-f32d41a6e14f
docs
python
python_stdtypes
312
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_312.md
54a6b085-6512-53bf-8e4b-bc3556361e9f
docs
python
python_stdtypes
312
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_312.md
9bfdd19c-7d98-5c89-bd97-b3937eb50b73
docs
python
python_stdtypes
312
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_312.md
fa8257e5-44db-5080-8606-a58c77f4246d
docs
python
python_stdtypes
312
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_312.md
6ac441f9-beb5-5a3b-8442-13039471de72
docs
python
python_stdtypes
312
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* | | | `s.index(x[, i[, j]])` | index of the first occurrence of *x* in *s* (at or after index *i* and before index *j*) | (8) | | `s.count(x)` | t...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
75b90cf8-6bf7-54db-9dfb-eb32d18626be
docs
python
python_stdtypes
312
35
[`IndexError`](exceptions.html#IndexError "IndexError") or a [`StopIteration`](exceptions.html#StopIteration "StopIteration") is encountered (or when the index drops below zero). Notes: 1. While the `in` and `not in` operations are used only for simple containment testing in the general case, some specialised sequ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
c287a3a0-6a9b-5445-ad0d-44f98055d555
docs
python
python_stdtypes
312
36
list, so all three elements of `[[]] * 3` are references to this single empty list. Modifying any of the elements of `lists` modifies this single list. You can create a list of different lists this way: ```None >>> lists = [[] for i in range(3)] >>> lists[0].append(3) >>> lists[1].append(5) >>>...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
66b60b06-9eec-55be-82ae-88c54ad8a399
docs
python
python_stdtypes
312
37
5. The slice of *s* from *i* to *j* with step *k* is defined as the sequence of items with index `x = i + n*k` such that `0 <= n < (j-i)/k`. In other words, 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 r...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
ba696dfa-602e-5fc2-b385-787cb603e6d9
docs
python
python_stdtypes
312
38
[`str.join()`](#str.join "str.join") at the end or else write to an [`io.StringIO`](io.html#io.StringIO "io.StringIO") instance and retrieve its value when complete * if concatenating [`bytes`](#bytes "bytes") objects, you can similarly use [`bytes.join()`](#bytes.join "bytes.join") or [`io.BytesIO`](...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
82000b91-1f51-5fcc-9cff-f29df6464d70
docs
python
python_stdtypes
312
39
Not all implementations support passing the additional arguments *i* and *j*. These arguments allow efficient searching of subsections of the sequence. Passing the extra arguments is roughly equivalent to using `s[i:j].index(x)`, only without copying any data and with the returned index being relative to ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
1c97bfd2-d494-53fd-9402-04f4f521df04
docs
python
python_stdtypes
312
40
### Mutable Sequence Types[¶](#mutable-sequence-types "Link to this heading") The operations in the following table are defined on mutable sequence types. The [`collections.abc.MutableSequence`](collections.abc.html#collections.abc.MutableSequence "collections.abc.MutableSequence") ABC is provided to make it easier to...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
e45516ae-d10a-5f3e-ab9e-743174b89ef7
docs
python
python_stdtypes
312
41
| `del s[i:j:k]` | removes the elements of `s[i:j:k]` from the list | | | `s.append(x)` | appends *x* to the end of the sequence (same as `s[len(s):len(s)] = [x]`) | | | `s.clear()` | removes all items from *s* (same as `del s[:]`) | (5) | | `s.copy()` | creates a shallow copy of *s* (same as `s[:]`) | (5) | | `s.ext...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
9e9d8b40-d7fe-564c-bace-4c1b63f41c91
docs
python
python_stdtypes
312
42
item is removed and returned. 3. `remove()` raises [`ValueError`](exceptions.html#ValueError "ValueError") when *x* is not found in *s*. 4. The `reverse()` method modifies the sequence in place for economy of space when reversing a large sequence. To remind users that it operates by side effect, it does not re...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
2b0c4e3b-41e9-5d3e-bace-57e915b729a0
docs
python
python_stdtypes
312
43
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). ### Lists[¶](#lists "Link to this heading") Lists are mutable sequences, typically used to store collections of homogeneous items (where the prec...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
68d03b54-7680-586e-bba4-c5e96d2c3453
docs
python
python_stdtypes
312
44
is already a list, a copy is made and returned, similar to `iterable[:]`. For example, `list('abc')` returns `['a', 'b', 'c']` and `list( (1, 2, 3) )` returns `[1, 2, 3]`. If no argument is given, the constructor creates a new empty list, `[]`. Many other operations also produce lists, including th...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
e44f2784-c646-5350-8461-607210dd10c5
docs
python
python_stdtypes
312
45
([keyword-only arguments](../glossary.html#keyword-only-parameter)): *key* specifies a function of one argument that is used to extract a comparison key from each list element (for example, `key=str.lower`). The key corresponding to each item in the list is calculated once and t...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
ec72429a-7776-5883-908d-c7a15bdb2684
docs
python
python_stdtypes
312
46
effect, it does not return the sorted sequence (use [`sorted()`](functions.html#sorted "sorted") to explicitly request a new sorted list instance). The [`sort()`](#list.sort "list.sort") method is guaranteed to be stable. A sort is stable if it guarantees not to change the relative orde...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
a4844b63-4f51-5236-b6e3-c813f2c4d007
docs
python
python_stdtypes
312
47
### Tuples[¶](#tuples "Link to this heading") Tuples are immutable sequences, typically used to store collections of heterogeneous data (such as the 2-tuples produced by the [`enumerate()`](functions.html#enumerate "enumerate") built-in). Tuples are also used for cases where an immutable sequence of homogeneous data i...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
80611942-1e69-583b-a275-6ee5854155d9
docs
python
python_stdtypes
312
48
container that supports iteration, or an iterator object. If *iterable* is already a tuple, it is returned unchanged. For example, `tuple('abc')` returns `('a', 'b', 'c')` and `tuple( [1, 2, 3] )` returns `(1, 2, 3)`. If no argument is given, the constructor creates a new empty tuple, `()`. Not...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
1342f07a-b39d-5cc7-a58e-190779ae3368
docs
python
python_stdtypes
312
49
### Ranges[¶](#ranges "Link to this heading") The [`range`](#range "range") type represents an immutable sequence of numbers and is commonly used for looping a specific number of times in [`for`](../reference/compound_stmts.html#for) loops. *class* range(*stop*)[¶](#range "Link to this definition") *class* range(*st...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
cf16c24d-feea-50c8-84cb-8acb5b637009
docs
python
python_stdtypes
312
50
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] > stop`. A range object will be empty if `r[0]` does not meet the value constraint. Ranges do support negative indices, but these are interpreted ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
c4a3638c-3e32-506b-a807-664b71e2af20
docs
python
python_stdtypes
312
51
>>> list(range(0)) [] >>> list(range(1, 0)) [] ``` Ranges implement all of the [common](#typesseq-common) sequence operations except concatenation and repetition (due to the fact that range objects can only represent sequences that follow a strict pattern and repetition and concaten...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
2efd5758-e11b-57d8-9e01-66245bf65efe
docs
python
python_stdtypes
312
52
only stores the `start`, `stop` and `step` values, calculating individual items and subranges as needed). Range objects implement the [`collections.abc.Sequence`](collections.abc.html#collections.abc.Sequence "collections.abc.Sequence") ABC, and provide features such as containment tests, element index lookup, slicing...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
0d907e29-cabb-5e05-a824-c4af1fff872e
docs
python
python_stdtypes
312
53
`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 slicing and negative indices. Test [`int`](functions.html#int "int") objects for membership in constant time instead of iterating through all items. Changed in version 3.3: Define ‘==’ and ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
ccd47e4b-ab43-5b29-a45b-217ff8ae374a
docs
python
python_stdtypes
312
54
[sequences](#typesseq) of Unicode code points. String literals are written in a variety of ways: * Single quotes: `'allows embedded "double" quotes'` * Double quotes: `"allows embedded 'single' quotes"` * Triple quoted: `'''Three single quotes'''`, `"""Three double quotes"""` Triple quoted strings may span multiple l...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
2017e43a-0b7e-5000-b4dd-0d66553c0573
docs
python
python_stdtypes
312
55
Since there is no separate “character” type, indexing a string produces strings of length 1. That is, for a non-empty string *s*, `s[0] == s[0:1]`. There is also no mutable string type, but [`str.join()`](#str.join "str.join") or [`io.StringIO`](io.html#io.StringIO "io.StringIO") can be used to efficiently construct s...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
624d3a2e-b074-5384-9249-75e37e614239
docs
python
python_stdtypes
312
56
[`type(object).__str__(object)`](../reference/datamodel.html#object.__str__ "object.__str__"), which is the “informal” or nicely printable string representation of *object*. For string objects, this is the string itself. If *object* does not have a [`__str__()`](../reference/datamodel.html#object.__str_...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
e5578ce7-2e28-5bd7-96f9-b32629786e0f
docs
python
python_stdtypes
312
57
[`bytes.decode()`](#bytes.decode "bytes.decode"). See [Binary Sequence Types — bytes, bytearray, memoryview](#binaryseq) and [Buffer Protocol](../c-api/buffer.html#bufferobjects) for information on buffer objects. Passing a [`bytes`](#bytes "bytes") object to [`str()`](#str "str") without the *encoding* ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
ce583d5b-7f31-5530-be2d-914b90fc5693
docs
python
python_stdtypes
312
58
### String Methods[¶](#string-methods "Link to this heading") Strings implement all of the [common](#typesseq-common) sequence operations, along with the additional methods described below. Strings also support two styles of string formatting, one providing a large degree of flexibility and customization (see [`str.f...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
589868f1-0f7a-56d9-9187-37ea1a784575
docs
python
python_stdtypes
312
59
str.capitalize()[¶](#str.capitalize "Link to this definition") : Return a copy of the string with its first character capitalized and the rest lowercased. Changed in version 3.8: The first character is now put into titlecase rather than uppercase. This means that characters like digraphs will only have t...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
fceadb9a-0124-5861-aead-d79141f713f9
docs
python
python_stdtypes
312
60
[described in section 3.13 ‘Default Case Folding’ of the Unicode Standard](https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf). Added in version 3.3. str.center(*width*[, *fillchar*])[¶](#str.center "Link to this definition") : Return centered in a string of length *width*. Padding is done using the ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
af7218da-c37c-551f-bbf5-9c8838e00a33
docs
python
python_stdtypes
312
61
*encoding* defaults to `'utf-8'`; see [Standard Encodings](codecs.html#standard-encodings) for possible values. *errors* controls how encoding errors are handled. If `'strict'` (the default), a [`UnicodeError`](exceptions.html#UnicodeError "UnicodeError") exception is raised. Other possible values ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
05263de8-865b-592b-ac4f-8b9dfc5fc6a9
docs
python
python_stdtypes
312
62
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_312.md
06674801-64da-5e0d-bd14-37e8a1ee7671
docs
python
python_stdtypes
312
63
the character is a tab (`\t`), one or more space characters are inserted in the result until the current column is equal to the next tab position. (The tab character itself is not copied.) If the character is a newline (`\n`) or return (`\r`), it is copied and the current column is reset to zero. An...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
66dbcaef-c6f0-5865-b09e-bac1d868340f
docs
python
python_stdtypes
312
64
The [`find()`](#str.find "str.find") method should be used only if you need to know the position of *sub*. To check if *sub* is a substring or not, use the [`in`](../reference/expressions.html#in) operator: ```None >>> 'Py' in 'Python' True ``` str.format(*\*args*, *\*\*kwargs*)[¶](#str.fo...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
57bc8f84-e74a-5311-b631-12af2b5da55c
docs
python
python_stdtypes
312
65
Note 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 tempo...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
5375dabb-36af-5742-9ca7-2d412f63086f
docs
python
python_stdtypes
312
66
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_312.md
e3128864-1b4f-5228-9fe8-aa7ef01668ac
docs
python
python_stdtypes
312
67
one character, `False` otherwise. Alphabetic characters are those characters defined in the Unicode character database as “Letter”, i.e., those with general category property being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”. Note that this is different from the [Alphabetic property defined in the section 4....
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
336a9a56-c784-56eb-a516-a6fd1a190904
docs
python
python_stdtypes
312
68
ZERO. Formally a decimal character is a character in the Unicode General Category “Nd”. 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 include decimal characters and digits ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
dde97969-cea8-50c5-8a0d-932fd09a910c
docs
python
python_stdtypes
312
69
identifier, such as [`def`](../reference/compound_stmts.html#def) and [`class`](../reference/compound_stmts.html#class). Example: ```None >>> from keyword import iskeyword >>> 'hello'.isidentifier(), iskeyword('hello') (True, False) >>> 'def'.isidentifier(), iskeyword('def') (True, Tr...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
e59ea2a1-93b0-59df-9202-8d969f2e20bf
docs
python
python_stdtypes
312
70
value Numeric\_Type=Digit, Numeric\_Type=Decimal or Numeric\_Type=Numeric. str.isprintable()[¶](#str.isprintable "Link to this definition") : Return true if all characters in the string are printable, false if it contains at least one non-printable character. Here “printable” means the character is suit...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
b77d9367-1afb-5f34-b58f-75d9200ae129
docs
python
python_stdtypes
312
71
Nonprintable characters are those in group Separator or Other (Z or C), except the ASCII space. str.isspace()[¶](#str.isspace "Link to this definition") : Return `True` if there are only whitespace characters in the string and there is at least one character, `False` otherwise. A character is *white...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
bb6f63a0-a829-5857-b9d8-213bafa7a154
docs
python
python_stdtypes
312
72
: 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_312.md
510c283c-57fb-5b47-a0ae-574e11b743da
docs
python
python_stdtypes
312
73
str.lower()[¶](#str.lower "Link to this definition") : Return a copy of the string with all the cased characters [[4]](#id15) converted to lowercase. The lowercasing algorithm used is [described in section 3.13 ‘Default Case Folding’ of the Unicode Standard](https://www.unicode.org/versions/Unicode15.0.0...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
e77ef45e-51d4-5499-bba2-098b66c35aed
docs
python
python_stdtypes
312
74
string rather than all of a set of characters. For example: ```None >>> 'Arthur: three!'.lstrip('Arthur: ') 'ee!' >>> 'Arthur: three!'.removeprefix('Arthur: ') 'three!' ``` *static* str.maketrans(*x*[, *y*[, *z*]])[¶](#str.maketrans "Link to this definition") : This static method returns...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
c5fb0a7f-d045-533c-8783-511104195f97
docs
python
python_stdtypes
312
75
str.partition(*sep*)[¶](#str.partition "Link to this definition") : Split the string at the first occurrence of *sep*, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing the strin...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
4b88c2fd-ab8f-58f0-8170-fd24b310c5ea
docs
python
python_stdtypes
312
76
>>> 'MiscTests'.removesuffix('Tests') 'Misc' >>> 'TmpDirMixin'.removesuffix('Tests') 'TmpDirMixin' ``` Added in version 3.9. str.replace(*old*, *new*[, *count*])[¶](#str.replace "Link to this definition") : Return a copy of the string with all occurrences of substring *old* replaced by *...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
1db5efa6-4091-543b-b76b-17b50a679048
docs
python
python_stdtypes
312
77
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.rpartition...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
f0f95d00-5bf3-5288-af42-56b49699f01f
docs
python
python_stdtypes
312
78
separator. Except for splitting from the right, [`rsplit()`](#str.rsplit "str.rsplit") behaves like [`split()`](#str.split "str.split") which is described in detail below. str.rstrip([*chars*])[¶](#str.rstrip "Link to this definition") : Return a copy of the string with trailing characters removed. The *char...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
af9c7391-4b7e-53f4-971c-7eea9681a741
docs
python
python_stdtypes
312
79
str.split(*sep=None*, *maxsplit=-1*)[¶](#str.split "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 (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
9beb4af4-015b-5ae0-b248-948dffd54e5f
docs
python
python_stdtypes
312
80
['1', '2', '', '3', ''] >>> '1<>2<>3<4'.split('<>') ['1', '2', '3<4'] ``` If *sep* is not specified or is `None`, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end i...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
7138b72c-21d3-5364-9443-282c8ad6c155
docs
python
python_stdtypes
312
81
boundaries are a superset of [universal newlines](../glossary.html#term-universal-newlines). | Representation | Description | | --- | --- | | `\n` | Line Feed | | `\r` | Carriage Return | | `\r\n` | Carriage Return + Line Feed | | `\v` or `\x0b` | Line Tabulation | | `\f` or `\x0c` | Fo...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
861f7132-d583-59d1-be04-1f12eb9f6b24
docs
python
python_stdtypes
312
82
break does not result in an extra line: ```None >>> "".splitlines() [] >>> "One line\n".splitlines() ['One line'] ``` For comparison, `split('\n')` gives: ```None >>> ''.split('\n') [''] >>> 'Two lines\n'.split('\n') ['Two lines', ''] ``` str.startswith(*prefi...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
8452eb2a-8352-5d36-a2eb-e06c8b378be3
docs
python
python_stdtypes
312
83
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_312.md
cadb5eba-7987-5c38-975a-bf49c5ee46aa
docs
python
python_stdtypes
312
84
: Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase. For example: ```None >>> 'Hello world'.title() 'Hello World' ``` The algorithm uses a simple language-independent definition of a word as groups of c...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
45db95ed-696c-561e-b0c3-5550b9e4ccb0
docs
python
python_stdtypes
312
85
... lambda mo: mo.group(0).capitalize(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." ``` str.translate(*table*)[¶](#str.translate "Link to this definition") : Return a copy of the string in which each character has been map...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
5a51f70c-acd2-56e8-bef9-ac057b1cc4e1
docs
python
python_stdtypes
312
86
You can use [`str.maketrans()`](#str.maketrans "str.maketrans") to create a translation map from character-to-character mappings in different formats. See also the [`codecs`](codecs.html#module-codecs "codecs: Encode and decode data and streams.") module for a more flexible approach to custom character...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
bb6dddf4-91dd-51d2-b715-18a079eb9da1
docs
python
python_stdtypes
312
87
make a string of length *width*. A leading sign prefix (`'+'`/`'-'`) is handled by inserting the padding *after* the sign character rather than before. The original string is returned if *width* is less than or equal to `len(s)`. For example: ```None >>> "42".zfill(5) '00042' >>> "...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
251edab2-0903-523d-841b-28f2254b52d7
docs
python
python_stdtypes
312
88
String objects have one unique built-in operation: the `%` operator (modulo). This is also known as the string *formatting* or *interpolation* operator. Given `format % values` (where *format* is a string), `%` conversion specifications in *format* are replaced with zero or more elements of *values*. The effect is simi...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
7f9cf1ca-50e5-57b7-b320-0f53f2113bd5
docs
python
python_stdtypes
312
89
4. Minimum field width (optional). If specified as an `'*'` (asterisk), the actual width is read from the next element of the tuple in *values*, and the object to convert comes after the minimum field width and optional precision. 5. Precision (optional), given as a `'.'` (dot) followed by the precision. If sp...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
9ec90675-d00e-5226-bf85-34343065e854
docs
python
python_stdtypes
312
90
In this case no `*` specifiers may occur in a format (since they require a sequential parameter list). The conversion flag characters are: | Flag | Meaning | | --- | --- | | `'#'` | The value conversion will use the “alternate form” (where defined below). | | `'0'` | The conversion will be zero padded for numeric val...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
131b39df-1849-512d-855a-6e67ee300611
docs
python
python_stdtypes
312
91
| `'u'` | Obsolete type – it is identical to `'d'`. | (6) | | `'x'` | Signed hexadecimal (lowercase). | (2) | | `'X'` | Signed hexadecimal (uppercase). | (2) | | `'e'` | Floating-point exponential format (lowercase). | (3) | | `'E'` | Floating-point exponential format (uppercase). | (3) | | `'f'` | Floating-point decim...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
d3265cd9-b20c-598f-b5b2-1fbdfaf607a7
docs
python
python_stdtypes
312
92
| `'a'` | String (converts any Python object using [`ascii()`](functions.html#ascii "ascii")). | (5) | | `'%'` | No argument is converted, results in a `'%'` character in the result. | | Notes: 1. The alternate form causes a leading octal specifier (`'0o'`) to be inserted before the first digit. 2. The alternate ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
a433a420-3669-5448-8bd1-1119a4cce98e
docs
python
python_stdtypes
312
93
6. See [**PEP 237**](https://peps.python.org/pep-0237/). Since Python strings have an explicit length, `%s` conversions do not assume that `'\0'` is the end of the string. Changed in version 3.1: `%f` conversions for numbers whose absolute value is over 1e50 are no longer replaced by `%g` conversions. ## Binary Sequ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
14b5636b-044d-5e96-a073-a63573a8268a
docs
python
python_stdtypes
312
94
32-bit integers and IEEE754 double-precision floating values. ### Bytes Objects[¶](#bytes-objects "Link to this heading") Bytes objects are immutable sequences of single bytes. Since many major binary protocols are based on the ASCII text encoding, bytes objects offer several methods that are only valid when working ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
233cf08a-00ae-5cd9-87bb-cee41755676f
docs
python
python_stdtypes
312
95
into bytes literals using the appropriate escape sequence. As with string literals, bytes literals may also use a `r` prefix to disable processing of escape sequences. See [String and Bytes literals](../reference/lexical_analysis.html#strings) for more about the various forms of bytes literal, includin...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
0b41aca5-eb54-5598-985a-5356db77c9d7
docs
python
python_stdtypes
312
96
compatible will usually lead to data corruption). In addition to the literal forms, bytes objects can be created in a number of other ways: * A zero-filled bytes object of a specified length: `bytes(10)` * From an iterable of integers: `bytes(range(20))` * Copying existing binary data via the ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
3010c6c1-3420-5110-a822-01cec8842e8d
docs
python
python_stdtypes
312
97
b'.\xf0\xf1\xf2' ``` Changed in version 3.7: [`bytes.fromhex()`](#bytes.fromhex "bytes.fromhex") now skips all ASCII whitespace in the string, not just spaces. A reverse conversion function exists to transform a bytes object into its hexadecimal representation. hex([*sep*[...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
ba36fdf2-0892-5bf9-a72f-b6fb50b79975
docs
python
python_stdtypes
312
98
>>> value = b'\xf0\xf1\xf2' >>> value.hex('-') 'f0-f1-f2' >>> value.hex('_', 2) 'f0_f1f2' >>> b'UUDDLRLRAB'.hex(' ', -4) '55554444 4c524c52 4142' ``` Added in version 3.5. Changed in version 3.8: [`bytes.hex()`](#bytes.hex "bytes.hex") no...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
7affffb0-a379-5229-90d0-6be0fdefa1d4
docs
python
python_stdtypes
312
99
### Bytearray Objects[¶](#bytearray-objects "Link to this heading") [`bytearray`](#bytearray "bytearray") objects are a mutable counterpart to [`bytes`](#bytes "bytes") objects. *class* bytearray([*source*[, *encoding*[, *errors*]]])[¶](#bytearray "Link to this definition") : There is no dedicated literal syntax fo...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
7f9a3089-2fc0-5faa-b6d2-6b43fdb57185
docs
python
python_stdtypes
312
100
Since 2 hexadecimal digits correspond precisely to a single byte, hexadecimal numbers are a commonly used format for describing binary data. Accordingly, the bytearray type has an additional class method to read data in that format: *classmethod* fromhex(*string*)[¶](#bytearray.fromhex "Link to this de...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
76367fce-39a9-53f9-8c7e-794bd639c7ed
docs
python
python_stdtypes
312
101
hex([*sep*[, *bytes\_per\_sep*]])[¶](#bytearray.hex "Link to this definition") : Return a string object containing two hexadecimal digits for each byte in the instance. ```None >>> bytearray(b'\xf0\xf1\xf2').hex() 'f0f1f2' ``` Added in version 3.5. Ch...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
76922781-e5f9-5ccc-9a79-c9106481a516
docs
python
python_stdtypes
312
102
`bytearray([46, 46, 46])`. You can always convert a bytearray object into a list of integers using `list(b)`. ### Bytes and Bytearray Operations[¶](#bytes-and-bytearray-operations "Link to this heading") Both bytes and bytearray objects support the [common](#typesseq-common) sequence operations. They interoperate not...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
f22e4f50-a27f-5340-870d-8d5ad7472346
docs
python
python_stdtypes
312
103
binary formats, and hence should be avoided when working with arbitrary binary data. These restrictions are covered below. Note Using these ASCII based operations to manipulate binary data that is not stored in an ASCII based format may lead to data corruption. The following methods on bytes and bytearray objects ca...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
f3ded5be-17b9-5616-9671-30ba30749ac9
docs
python
python_stdtypes
312
104
Changed in version 3.3: Also accept an integer in the range 0 to 255 as the subsequence. bytes.removeprefix(*prefix*, */*)[¶](#bytes.removeprefix "Link to this definition") bytearray.removeprefix(*prefix*, */*)[¶](#bytearray.removeprefix "Link to this definition") : If the binary data starts with the *prefix* s...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
8520fba2-13ad-541e-84de-6e235669b415
docs
python
python_stdtypes
312
105
: If the binary data ends with the *suffix* string and that *suffix* is not empty, return `bytes[:-len(suffix)]`. Otherwise, return a copy of the original binary data: ```None >>> b'MiscTests'.removesuffix(b'Tests') b'Misc' >>> b'TmpDirMixin'.removesuffix(b'Tests') b'TmpDirMixin' ``` ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
b11a0095-5476-5483-8e47-5e0d7584c86d
docs
python
python_stdtypes
312
106
If `'strict'` (the default), a [`UnicodeError`](exceptions.html#UnicodeError "UnicodeError") exception is raised. Other possible values are `'ignore'`, `'replace'`, and any other name registered via [`codecs.register_error()`](codecs.html#codecs.register_error "codecs.register_error"). See [Error Handle...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
633462b1-2c95-5913-b3f2-4ffc22255f85
docs
python
python_stdtypes
312
107
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). bytes.endswith(*suffix*[, *start*[, *end*]])[¶](#bytes.endswith "Link to this definition") bytearray.endswith(*suffix*[, *start...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
903eec53-8498-5f55-a72c-97348df5fdbe
docs
python
python_stdtypes
312
108
such that *sub* is contained in the slice `s[start:end]`. Optional arguments *start* and *end* are interpreted as in slice notation. Return `-1` if *sub* is not found. The subsequence to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object) or an integer in the range 0 ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
285915c7-c6cc-577b-b55c-fbbdafeacdf0
docs
python
python_stdtypes
312
109
subsequence is not found. The subsequence to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object) or an integer in the range 0 to 255. Changed in version 3.3: Also accept an integer in the range 0 to 255 as the subsequence. bytes.join(*iterable*)[¶](#bytes.join "Link to ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
63772dc3-2072-5e65-aaec-02a347e1eea2
docs
python
python_stdtypes
312
110
*static* bytearray.maketrans(*from*, *to*)[¶](#bytearray.maketrans "Link to this definition") : This static method returns a translation table usable for [`bytes.translate()`](#bytes.translate "bytes.translate") that will map each character in *from* into the character at the same position in *to*; *from* and...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
3832d712-2f94-55b9-9da9-6fe8f0114058
docs
python
python_stdtypes
312
111
The separator to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object). bytes.replace(*old*, *new*[, *count*])[¶](#bytes.replace "Link to this definition") bytearray.replace(*old*, *new*[, *count*])[¶](#bytearray.replace "Link to this definition") : Return a copy of the sequence wit...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
628362b0-b2e0-5518-9c6a-fc1b5ef607d4
docs
python
python_stdtypes
312
112
found, such that *sub* is contained within `s[start:end]`. Optional arguments *start* and *end* are interpreted as in slice notation. Return `-1` on failure. The subsequence to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object) or an integer in the range 0 to 255. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
269c864a-0abd-5db2-9ef2-1c885b1d2481
docs
python
python_stdtypes
312
113
bytes.rpartition(*sep*)[¶](#bytes.rpartition "Link to this definition") bytearray.rpartition(*sep*)[¶](#bytearray.rpartition "Link to this definition") : Split the sequence at the last occurrence of *sep*, and return a 3-tuple containing the part before the separator, the separator itself or its bytearray co...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
c728d88b-6a05-5a1f-80f7-5c33573868b6
docs
python
python_stdtypes
312
114
look for. With optional *start*, test beginning at that position. With optional *end*, stop comparing at that position. The prefix(es) to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object). bytes.translate(*table*, */*, *delete=b''*)[¶](#bytes.translate "Link to this defini...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md
165f58cc-ea0a-51ca-9854-3f6b7d5ffd3e
docs
python
python_stdtypes
312
115
Changed in version 3.6: *delete* is now supported as a keyword argument. The following methods on bytes and bytearray objects have default behaviours that assume the use of ASCII compatible binary formats, but can still be used with arbitrary binary data by passing appropriate arguments. Note that all of the bytea...
large_dataset/raw/docs/python/stdtypes/stdtypes_312.md