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
16561f56-b3c2-5f37-ac1d-76872dfbefad
docs
python
python_stdtypes
311
38
### Immutable Sequence Types[¶](#immutable-sequence-types "Link to this heading") The only operation that immutable sequence types generally implement that is not also implemented by mutable sequence types is support for the [`hash()`](functions.html#hash "hash") built-in. This support allows immutable sequences, suc...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
8200b44a-4693-5c1f-a2e0-b936d390403b
docs
python
python_stdtypes
311
39
In the table *s* is an instance of a mutable sequence type, *t* is any iterable object and *x* is an arbitrary object that meets any type and value restrictions imposed by *s* (for example, [`bytearray`](#bytearray "bytearray") only accepts integers that meet the value restriction `0 <= x <= 255`). | Operation | Resul...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
4b73b048-e7bf-5a79-ba5a-2aebca3fd4b1
docs
python
python_stdtypes
311
40
| `s.extend(t)` or `s += t` | extends *s* with the contents of *t* (for the most part the same as `s[len(s):len(s)] = t`) | | | `s *= n` | updates *s* with its contents repeated *n* times | (6) | | `s.insert(i, x)` | inserts *x* into *s* at the index given by *i* (same as `s[i:i] = [x]`) | | | `s.pop()` or `s.pop(i)`...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
e783da09-b2cb-5054-939c-14c0f3df2278
docs
python
python_stdtypes
311
41
side effect, it does not return the reversed sequence. 5. `clear()` and `copy()` are included for consistency with the interfaces of mutable containers that don’t support slicing operations (such as [`dict`](#dict "dict") and [`set`](#set "set")). `copy()` is not part of the [`collections.abc.MutableSequenc...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
12398e95-8615-52e8-b1d6-8ad078d13aa7
docs
python
python_stdtypes
311
42
### Lists[¶](#lists "Link to this heading") Lists are mutable sequences, typically used to store collections of homogeneous items (where the precise degree of similarity will vary by application). *class* list([*iterable*])[¶](#list "Link to this definition") : Lists may be constructed in several ways: * Using...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
1cdd9250-bfc8-59b6-b85e-699222203af2
docs
python
python_stdtypes
311
43
If no argument is given, the constructor creates a new empty list, `[]`. Many other operations also produce lists, including the [`sorted()`](functions.html#sorted "sorted") built-in. Lists implement all of the [common](#typesseq-common) and [mutable](#typesseq-mutable) sequence operations. Lists ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
d3ef309f-706b-596d-b463-28a161304236
docs
python
python_stdtypes
311
44
comparison key from each list element (for example, `key=str.lower`). The key corresponding to each item in the list is calculated once and then used for the entire sorting process. The default value of `None` means that list items are sorted directly without calculating a separate ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
63caa7d5-af73-5618-8de2-cceb0ef28a9e
docs
python
python_stdtypes
311
45
The [`sort()`](#list.sort "list.sort") method is guaranteed to be stable. A sort is stable if it guarantees not to change the relative order of elements that compare equal — this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade). F...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
7c278c76-3a43-5ff4-8654-c1990a01ffbb
docs
python
python_stdtypes
311
46
### 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_311.md
26ca323e-797c-573d-adc7-8e2975a20a41
docs
python
python_stdtypes
311
47
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_311.md
c20f0b6e-884a-557b-890b-6b37b763aba3
docs
python
python_stdtypes
311
48
### 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_311.md
0a5b2211-8122-58c1-9b02-3d52fc1a0f81
docs
python
python_stdtypes
311
49
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_311.md
41ae8141-7450-518e-a3c2-4fdcc0b2dac7
docs
python
python_stdtypes
311
50
>>> 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_311.md
305c8dcd-205d-5b81-8b08-6f97e798ff67
docs
python
python_stdtypes
311
51
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_311.md
d81b20a4-c1b1-5070-85d5-f3078e09f74b
docs
python
python_stdtypes
311
52
`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_311.md
9acbdf4a-633a-5242-bf4b-bb952f10a74c
docs
python
python_stdtypes
311
53
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 lines - all associated whitespace will be included in the string lit...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
a1b7091b-d610-5dff-9384-1a39b0f74c93
docs
python
python_stdtypes
311
54
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 strings from multiple fragments. Changed in version 3.3: For backwards c...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
69b3a939-2f20-5e44-b866-703446571a79
docs
python
python_stdtypes
311
55
[`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_311.md
ddc8cc22-97e7-5be1-afd2-59753c9e6a8c
docs
python
python_stdtypes
311
56
[`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_311.md
784af761-f270-5adc-811b-c123a22a9c2d
docs
python
python_stdtypes
311
57
### 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_311.md
9bb410ea-5c0f-5149-86ce-cb70224b206c
docs
python
python_stdtypes
311
58
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_311.md
f9deff2d-ce53-5728-b174-c941e3dc1ebd
docs
python
python_stdtypes
311
59
New 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 specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`. str.c...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
61348aa6-2a0d-5435-b1bb-b4a9287cf08d
docs
python
python_stdtypes
311
60
*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_311.md
a2e34d7f-03c6-5eca-9355-9af6abdf600b
docs
python
python_stdtypes
311
61
str.endswith(*suffix*[, *start*[, *end*]])[¶](#str.endswith "Link to this definition") : Return `True` if the string ends with the specified *suffix*, otherwise return `False`. *suffix* can also be a tuple of suffixes to look for. With optional *start*, test beginning at that position. With optional *end*, st...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
ac3b3e09-13dd-5bab-9ae3-10182b46fa40
docs
python
python_stdtypes
311
62
(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. Any other character is copied unchanged and the current column is incremented by one regardless of how the character is represented when printed. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
cae0268d-2324-56e3-8188-280da1a7cb7f
docs
python
python_stdtypes
311
63
```None >>> 'Py' in 'Python' True ``` 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...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
443e215e-3796-54e9-b2b3-11b75d60039a
docs
python
python_stdtypes
311
64
[`decimal.Decimal`](decimal.html#decimal.Decimal "decimal.Decimal") and subclasses) with the `n` type (ex: `'{:n}'.format(1234)`), the function temporarily sets the `LC_CTYPE` locale to the `LC_NUMERIC` locale to decode `decimal_point` and `thousands_sep` fields of `localeconv()` if they are non-ASC...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
355a4882-4c25-5a75-8b73-5cccf696f371
docs
python
python_stdtypes
311
65
>>> '{name} was born in {country}'.format_map(Default(name='Guido')) 'Guido was born in country' ``` New in version 3.2. str.index(*sub*[, *start*[, *end*]])[¶](#str.index "Link to this definition") : Like [`find()`](#str.find "str.find"), but raise [`ValueError`](exceptions.html#ValueError "ValueEr...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
961aecd2-bb2a-5d37-95f0-26bd79ab41f8
docs
python
python_stdtypes
311
66
property being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”. Note that this is different from the “Alphabetic” property defined in the Unicode Standard. str.isascii()[¶](#str.isascii "Link to this definition") : Return `True` if the string is empty or all characters in the string are ASCII, `False` otherwise. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
d1c0cf83-c9c2-5d91-9f61-ff9794bf6c50
docs
python
python_stdtypes
311
67
character, `False` otherwise. Digits include decimal characters and digits that need special handling, such as the compatibility superscript digits. This covers digits which cannot be used to form numbers in base 10, like the Kharosthi numbers. Formally, a digit is a character that has the property ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
21a89dcd-6ffe-56da-a738-180c80f7bb24
docs
python
python_stdtypes
311
68
>>> 'def'.isidentifier(), iskeyword('def') (True, True) ``` str.islower()[¶](#str.islower "Link to this definition") : Return `True` if all cased characters [[4]](#id15) in the string are lowercase and there is at least one cased character, `False` otherwise. str.isnumeric()[¶](#str.isnumeric "Link ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
eab36253-5960-5bd2-98cd-64d6cb3b54bd
docs
python
python_stdtypes
311
69
in the Unicode character database as “Other” or “Separator”, excepting the ASCII space (0x20) which is considered printable. (Note that printable characters in this context are those which should not be escaped when [`repr()`](functions.html#repr "repr") is invoked on a string. It has no bearing on the ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
0c725ea2-83eb-5490-bc6f-c551ac810d01
docs
python
python_stdtypes
311
70
: Return `True` if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return `False` otherwise. str.isupper()[¶](#str.isupper "Link to this definition") : Return `True` if all c...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
6895be36-7ba8-596e-a9c1-b71780920052
docs
python
python_stdtypes
311
71
str.ljust(*width*[, *fillchar*])[¶](#str.ljust "Link to this definition") : 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)`. str.lower()[¶](...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
f2888f8b-c719-5f25-8635-2bbdb1e5ce1e
docs
python
python_stdtypes
311
72
>>> 'www.example.com'.lstrip('cmowz.') 'example.com' ``` See [`str.removeprefix()`](#str.removeprefix "str.removeprefix") for a method that will remove a single prefix string rather than all of a set of characters. For example: ```None >>> 'Arthur: three!'.lstrip('Arthur: ') 'ee!' ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
eaf3a837-ca2a-560d-9549-b014657bec7c
docs
python
python_stdtypes
311
73
the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to `None` in the result. 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 se...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
3f2e86c9-fc7b-5fcf-a8c1-aab65e38c0c2
docs
python
python_stdtypes
311
74
: If the string ends with the *suffix* string and that *suffix* is not empty, return `string[:-len(suffix)]`. Otherwise, return a copy of the original string: ```None >>> 'MiscTests'.removesuffix('Tests') 'Misc' >>> 'TmpDirMixin'.removesuffix('Tests') 'TmpDirMixin' ``` New in ver...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
0b7e286b-84ca-5e18-a4fa-81a721a63e8a
docs
python
python_stdtypes
311
75
: Like [`rfind()`](#str.rfind "str.rfind") but raises [`ValueError`](exceptions.html#ValueError "ValueError") when the substring *sub* is not found. str.rjust(*width*[, *fillchar*])[¶](#str.rjust "Link to this definition") : Return the string right justified in a string of length *width*. Padding is done u...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
710dac4c-207e-5b8c-b032-d3a20834635f
docs
python
python_stdtypes
311
76
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 separator. Except for splitting from the right, [`rsplit()`](#str.rsplit "str.rsplit") behaves like [`split()`](#str.split "str.split") which is described in ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
bd89b667-413f-587f-925e-d03e9840fc3a
docs
python
python_stdtypes
311
77
string rather than all of a set of characters. For example: ```None >>> 'Monty Python'.rstrip(' Python') 'M' >>> 'Monty Python'.removesuffix(' Python') 'Monty' ``` str.split(*sep=None*, *maxsplit=-1*)[¶](#str.split "Link to this definition") : Return a list of the words in the string, us...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
5e8c038d-eaaa-54bf-9c0a-768fef5e4421
docs
python
python_stdtypes
311
78
>>> '1,2,3'.split(',') ['1', '2', '3'] >>> '1,2,3'.split(',', maxsplit=1) ['1', '2,3'] >>> '1,2,,3,'.split(',') ['1', '2', '', '3', ''] ``` If *sep* is not specified or is `None`, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single sep...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
c1fb9657-d49c-53b8-acb8-d347abfc8798
docs
python
python_stdtypes
311
79
This method splits on the following line boundaries. In particular, the boundaries are a superset of [universal newlines](../glossary.html#term-universal-newlines). | Representation | Description | | --- | --- | | `\n` | Line Feed | | `\r` | Carriage Return | | `\r\n` | Carriage Return + Li...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
ba36cae0-b006-5384-a1ed-fbb01008dfda
docs
python
python_stdtypes
311
80
method returns an empty list for the empty string, and a terminal line break does not result in an extra line: ```None >>> "".splitlines() [] >>> "One line\n".splitlines() ['One line'] ``` For comparison, `split('\n')` gives: ```None >>> ''.split('\n') [''] >>> 'Tw...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
caa673ff-2829-5f64-bd1b-10bb14f39156
docs
python
python_stdtypes
311
81
If omitted or `None`, the *chars* argument defaults to removing whitespace. 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' ``` T...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
018a6e5d-f049-58db-bda0-3faf0a294942
docs
python
python_stdtypes
311
82
str.title()[¶](#str.title "Link to this definition") : 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 languag...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
aa7d80ee-3c5c-5d25-8f95-c49b7a4ca984
docs
python
python_stdtypes
311
83
... return re.sub(r"[A-Za-z]+('[A-Za-z]+)?", ... 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 co...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
6d711f04-4f83-5c54-8e0a-06f92765eac1
docs
python
python_stdtypes
311
84
[`LookupError`](exceptions.html#LookupError "LookupError") exception, to map the character to itself. 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...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
4c90e387-6631-58eb-8304-d35abbd3f55a
docs
python
python_stdtypes
311
85
: Return a copy of the string left filled with ASCII `'0'` digits to 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)`. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
84c0afc6-5e1d-5318-831f-45babadf5ff4
docs
python
python_stdtypes
311
86
flexibility, and/or extensibility. 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 elem...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
c85ca61a-0855-5a14-8037-a7da27e7e2d6
docs
python
python_stdtypes
311
87
3. Conversion flags (optional), which affect the result of some conversion types. 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...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
50a4dcc9-4bf8-58d0-96fe-ab709e893065
docs
python
python_stdtypes
311
88
... {'language': "Python", "number": 2}) Python has 002 quote types. ``` 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” (wher...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
b12c2c22-19f9-5072-9791-30736cd293c1
docs
python
python_stdtypes
311
89
| `'i'` | Signed integer decimal. | | | `'o'` | Signed octal value. | (1) | | `'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...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
716eb995-0a73-5f4b-a88e-1c58d538ca88
docs
python
python_stdtypes
311
90
| `'s'` | String (converts any Python object using [`str()`](#str "str")). | (5) | | `'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 o...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
5e51b84f-e436-5310-a0b8-d04c5ae15d17
docs
python
python_stdtypes
311
91
5. If precision is `N`, the output is truncated to `N` characters. 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 ov...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
7c0ec7e7-1f6a-5b90-8706-a5112886943b
docs
python
python_stdtypes
311
92
The [`array`](array.html#module-array "array: Space efficient arrays of uniformly typed numeric values.") module supports efficient storage of basic data types like 32-bit integers and IEEE754 double-precision floating values. ### Bytes Objects[¶](#bytes-objects "Link to this heading") Bytes objects are immutable seq...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
6b2c0d41-fbb4-5fa3-87e0-df32a8d92767
docs
python
python_stdtypes
311
93
Only ASCII characters are permitted in bytes literals (regardless of the declared source code encoding). Any binary values over 127 must be entered into bytes literals using the appropriate escape sequence. As with string literals, bytes literals may also use a `r` prefix to disable processing of e...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
89a3a3d9-404f-568c-b941-065026eabdff
docs
python
python_stdtypes
311
94
this is not generally the case for arbitrary binary data (blindly applying text processing algorithms to binary data formats that are not ASCII 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-f...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
e990b524-c0de-5ca4-b4b4-95a68901a3bf
docs
python
python_stdtypes
311
95
given string object. The string must contain two hexadecimal digits per byte, with ASCII whitespace being ignored. ```None >>> bytes.fromhex('2Ef0 F1f2 ') b'.\xf0\xf1\xf2' ``` Changed in version 3.7: [`bytes.fromhex()`](#bytes.fromhex "bytes.fromhex") now skips...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
ccfb9f63-467c-5afa-be7b-ecac59b3c851
docs
python
python_stdtypes
311
96
A second optional *bytes\_per\_sep* parameter controls the spacing. Positive values calculate the separator position from the right, negative values from the left. ```None >>> value = b'\xf0\xf1\xf2' >>> value.hex('-') 'f0-f1-f2' >>> value.hex('_', 2) ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
c0622c36-0b34-5977-b94e-21a35346df83
docs
python
python_stdtypes
311
97
since it is often more useful than e.g. `bytes([46, 46, 46])`. You can always convert a bytes object into a list of integers using `list(b)`. ### Bytearray Objects[¶](#bytearray-objects "Link to this heading") [`bytearray`](#bytearray "bytearray") objects are a mutable counterpart to [`bytes`](#bytes "bytes") objects...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
bc2af7e5-2fcd-5002-a72a-3c0e2fa80626
docs
python
python_stdtypes
311
98
common bytes and bytearray operations described in [Bytes and Bytearray Operations](#bytes-methods). Also see the [bytearray](functions.html#func-bytearray) built-in. Since 2 hexadecimal digits correspond precisely to a single byte, hexadecimal numbers are a commonly used format for describing binary ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
06590b82-b5f7-5c46-b309-4e8f2baa37e4
docs
python
python_stdtypes
311
99
A reverse conversion function exists to transform a bytearray object into its hexadecimal representation. 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 ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
89da775b-71b2-53ff-935b-7885d088e4ac
docs
python
python_stdtypes
311
100
The representation of bytearray objects uses the bytes literal format (`bytearray(b'...')`) since it is often more useful than e.g. `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 t...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
fbd520e8-d39e-5c71-8fd7-1b4f34f5914e
docs
python
python_stdtypes
311
101
Some bytes and bytearray operations assume the use of ASCII compatible 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 d...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
2b69ae42-cfcd-58fd-b2dc-17bd6787760e
docs
python
python_stdtypes
311
102
which is the length of the bytes object plus one. 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 definit...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
40f2835b-d03e-5eea-a41c-a3ea0623a7d6
docs
python
python_stdtypes
311
103
bytearray.removesuffix(*suffix*, */*)[¶](#bytearray.removesuffix "Link to this definition") : 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'T...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
8a895f39-4aee-547e-a6fe-5a23d03798cf
docs
python
python_stdtypes
311
104
see [Standard Encodings](codecs.html#standard-encodings) for possible values. *errors* controls how decoding errors are handled. If `'strict'` (the default), a [`UnicodeError`](exceptions.html#UnicodeError "UnicodeError") exception is raised. Other possible values are `'ignore'`, `'replace'`, and a...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
aa88f2fa-d45a-5056-87b7-eaeab541c8ed
docs
python
python_stdtypes
311
105
Changed in version 3.1: Added support for keyword arguments. 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.endswit...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
cd9a2bba-070f-5ac0-9fd5-b34b1ccc7723
docs
python
python_stdtypes
311
106
: Return the lowest index in the data where the subsequence *sub* is found, 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 obje...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
9bd09f79-c44b-538f-937f-8a62ce6b7a94
docs
python
python_stdtypes
311
107
: Like [`find()`](#bytes.find "bytes.find"), but raise [`ValueError`](exceptions.html#ValueError "ValueError") when the 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 vers...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
f4351dac-5d08-5b95-895d-c18e34702cda
docs
python
python_stdtypes
311
108
*static* bytes.maketrans(*from*, *to*)[¶](#bytes.maketrans "Link to this definition") *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 e...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
d2d261b4-48a8-57e5-98cc-f67392ef97ca
docs
python
python_stdtypes
311
109
containing a copy of the original sequence, followed by two empty bytes or bytearray objects. 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*, *...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
f27289d0-00e8-5e26-a4f8-c2f180816676
docs
python
python_stdtypes
311
110
bytearray.rfind(*sub*[, *start*[, *end*]])[¶](#bytearray.rfind "Link to this definition") : Return the highest index in the sequence where the subsequence *sub* is found, such that *sub* is contained within `s[start:end]`. Optional arguments *start* and *end* are interpreted as in slice notation. Return `...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
174813b9-efca-5177-bd96-e334a8ab02a8
docs
python
python_stdtypes
311
111
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.rpartition(*sep*)[¶](#bytes.rpartition "Link to this definition") bytea...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
37b008d4-36c6-53e1-8f7f-2b356533ba30
docs
python
python_stdtypes
311
112
bytearray.startswith(*prefix*[, *start*[, *end*]])[¶](#bytearray.startswith "Link to this definition") : Return `True` if the binary data starts with the specified *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test beginning at that position. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
be7c6c88-655e-5ba0-ba37-8bb05ac96cb4
docs
python
python_stdtypes
311
113
You can use the [`bytes.maketrans()`](#bytes.maketrans "bytes.maketrans") method to create a translation table. Set the *table* argument to `None` for translations that only delete characters: ```None >>> b'read this short text'.translate(None, b'aeiou') b'rd ths shrt txt' ``` Cha...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
42c96b19-a1ec-55fc-88ee-1c2f099d9f2c
docs
python
python_stdtypes
311
114
Padding is done using the specified *fillbyte* (default is an ASCII space). For [`bytes`](#bytes "bytes") objects, the original sequence is returned if *width* is less than or equal to `len(s)`. Note The bytearray version of this method does *not* operate in place - it always produces a new ob...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
d8f2325b-81df-5720-93d6-9f51bf535748
docs
python
python_stdtypes
311
115
bytes.lstrip([*chars*])[¶](#bytes.lstrip "Link to this definition") bytearray.lstrip([*chars*])[¶](#bytearray.lstrip "Link to this definition") : Return a copy of the sequence with specified leading bytes removed. The *chars* argument is a binary sequence specifying the set of byte values to be removed - the...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
2b13e82b-d74c-577f-8b94-578b478a3fed
docs
python
python_stdtypes
311
116
characters. For example: ```None >>> b'Arthur: three!'.lstrip(b'Arthur: ') b'ee!' >>> b'Arthur: three!'.removeprefix(b'Arthur: ') b'three!' ``` Note The bytearray version of this method does *not* operate in place - it always produces a new object, even if no changes were made...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
8e1837d2-1ff6-52b5-97e4-9073408c1448
docs
python
python_stdtypes
311
117
bytearray.rsplit(*sep=None*, *maxsplit=-1*)[¶](#bytearray.rsplit "Link to this definition") : Split the binary sequence into subsequences of the same type, 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`...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
7934cfae-07c8-5657-b518-839bfb283b7d
docs
python
python_stdtypes
311
118
ASCII characters. If omitted or `None`, the *chars* argument defaults to removing ASCII whitespace. The *chars* argument is not a suffix; rather, all combinations of its values are stripped: ```None >>> b' spacious '.rstrip() b' spacious' >>> b'mississippi'.rstrip(b'ipz') b'missis...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
d98081f6-1e3c-53f6-a327-0760b9371b2e
docs
python
python_stdtypes
311
119
bytearray.split(*sep=None*, *maxsplit=-1*)[¶](#bytearray.split "Link to this definition") : Split the binary sequence into subsequences of the same type, using *sep* as the delimiter string. If *maxsplit* is given and non-negative, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
3ce46e12-2a67-5802-a197-a6f653656b17
docs
python
python_stdtypes
311
120
[bytes-like object](../glossary.html#term-bytes-like-object). For example: ```None >>> b'1,2,3'.split(b',') [b'1', b'2', b'3'] >>> b'1,2,3'.split(b',', maxsplit=1) [b'1', b'2,3'] >>> b'1,2,,3,'.split(b',') [b'1', b'2', b'', b'3', b''] ``` If *sep* is not specified or is `N...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
55a0fc21-9969-5a23-ae39-c16239d319ef
docs
python
python_stdtypes
311
121
bytearray.strip([*chars*])[¶](#bytearray.strip "Link to this definition") : Return a copy of the sequence with specified leading and trailing bytes removed. The *chars* argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used w...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
535f546d-a98b-5a61-915b-add32c4f6bd7
docs
python
python_stdtypes
311
122
compatible binary formats and should not be applied to arbitrary binary data. Note that all of the bytearray methods in this section do *not* operate in place, and instead produce new objects. bytes.capitalize()[¶](#bytes.capitalize "Link to this definition") bytearray.capitalize()[¶](#bytearray.capitalize "Link to t...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
32859a30-567f-5c36-ad6a-6d4fe872274d
docs
python
python_stdtypes
311
123
tab size. Tab positions occur every *tabsize* bytes (default is 8, giving tab positions at columns 0, 8, 16 and so on). To expand the sequence, the current column is set to zero and the sequence is examined byte by byte. If the byte is an ASCII tab character (`b'\t'`), one or more space characters a...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
4f88e544-f3fe-5a90-bc05-f5978548c6bf
docs
python
python_stdtypes
311
124
always produces a new object, even if no changes were made. bytes.isalnum()[¶](#bytes.isalnum "Link to this definition") bytearray.isalnum()[¶](#bytearray.isalnum "Link to this definition") : Return `True` if all bytes in the sequence are alphabetical ASCII characters or ASCII decimal digits and the sequenc...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
d6301f8c-64fb-52a2-982c-3ed78c5ac3a8
docs
python
python_stdtypes
311
125
`b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'`. For example: ```None >>> b'ABCabc'.isalpha() True >>> b'ABCabc1'.isalpha() False ``` bytes.isascii()[¶](#bytes.isascii "Link to this definition") bytearray.isascii()[¶](#bytearray.isascii "Link to this definition") : Return...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
8c77d6f4-59ef-5f02-97b0-5c1d9d84ecb4
docs
python
python_stdtypes
311
126
bytearray.islower()[¶](#bytearray.islower "Link to this definition") : Return `True` if there is at least one lowercase ASCII character in the sequence and no uppercase ASCII characters, `False` otherwise. For example: ```None >>> b'hello world'.islower() True >>> b'Hello world'.islower() ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
c34a807f-dfd6-5c79-a203-50676f34368d
docs
python
python_stdtypes
311
127
bytearray.istitle()[¶](#bytearray.istitle "Link to this definition") : Return `True` if the sequence is ASCII titlecase and the sequence is not empty, `False` otherwise. See [`bytes.title()`](#bytes.title "bytes.title") for more details on the definition of “titlecase”. For example: ```None >>> ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
80d6d9ec-fc8f-52d6-802a-2a2eeadd5c23
docs
python
python_stdtypes
311
128
bytes.lower()[¶](#bytes.lower "Link to this definition") bytearray.lower()[¶](#bytearray.lower "Link to this definition") : Return a copy of the sequence with all the uppercase ASCII characters converted to their corresponding lowercase counterpart. For example: ```None >>> b'Hello World'.lower() ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
b8a29762-fce1-5287-92c4-9ca7c288de26
docs
python
python_stdtypes
311
129
line boundaries. This method uses the [universal newlines](../glossary.html#term-universal-newlines) approach to splitting lines. Line breaks are not included in the resulting list unless *keepends* is given and true. For example: ```None >>> b'ab c\n\nde fg\rkl\r\n'.splitlines() [b'ab c',...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
e45e5bd3-86b8-53b0-bd45-097e734c1000
docs
python
python_stdtypes
311
130
: Return a copy of the sequence with all the lowercase ASCII characters converted to their corresponding uppercase counterpart and vice-versa. For example: ```None >>> b'Hello World'.swapcase() b'hELLO wORLD' ``` Lowercase ASCII characters are those byte values in the sequence `b'ab...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
cf0e83ca-f071-541a-930b-3796ed545c9a
docs
python
python_stdtypes
311
131
: Return a titlecased version of the binary sequence where words start with an uppercase ASCII character and the remaining characters are lowercase. Uncased byte values are left unmodified. For example: ```None >>> b'Hello world'.title() b'Hello World' ``` Lowercase ASCII characters...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
8e6deb80-d0de-52a1-b41e-6a4e8acf0270
docs
python
python_stdtypes
311
132
```None >>> import re >>> def titlecase(s): ... return re.sub(rb"[A-Za-z]+('[A-Za-z]+)?", ... lambda mo: mo.group(0)[0:1].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase(b"they're bill's friends.") ...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
e65e17de-d421-506d-9b0e-f77d198b63cf
docs
python
python_stdtypes
311
133
are those byte values in the sequence `b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`. Note The bytearray version of this method does *not* operate in place - it always produces a new object, even if no changes were made. bytes.zfill(*width*)[¶](#bytes.zfill "Link to this definition") bytearray.zfill(*width*)[¶](#b...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
cc44252c-767b-5cdc-8e04-3965c9825e50
docs
python
python_stdtypes
311
134
### `printf`-style Bytes Formatting[¶](#printf-style-bytes-formatting "Link to this heading") Note The formatting operations described here exhibit a variety of quirks that lead to a number of common errors (such as failing to display tuples and dictionaries correctly). If the value being printed may be a tuple or di...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
387fcef6-ca23-5db2-a4a2-b92225e87498
docs
python
python_stdtypes
311
135
A conversion specifier contains two or more characters and has the following components, which must occur in this order: 1. The `'%'` character, which marks the start of the specifier. 2. Mapping key (optional), consisting of a parenthesised sequence of characters (for example, `(somename)`). 3. Conversion flags (o...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
0b6c676e-7a79-5691-8011-6e038d29e5a0
docs
python
python_stdtypes
311
136
formats in the bytes object *must* include a parenthesised mapping key into that dictionary inserted immediately after the `'%'` character. The mapping key selects the value to be formatted from the mapping. For example: ```None >>> print(b'%(language)s has %(number)03d quote types.' % ... {b'language': b"Python...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md
0035d8bb-177f-55b5-97be-e6e3aac8ce30
docs
python
python_stdtypes
311
137
A length modifier (`h`, `l`, or `L`) may be present, but is ignored as it is not necessary for Python – so e.g. `%ld` is identical to `%d`. The conversion types are: | Conversion | Meaning | Notes | | --- | --- | --- | | `'d'` | Signed integer decimal. | | | `'i'` | Signed integer decimal. | | | `'o'` | Signed oct...
large_dataset/raw/docs/python/stdtypes/stdtypes_311.md