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
b8e961c6-6251-5805-9bd9-792b30d06da5
docs
python
python_stdtypes
313
92
: 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_313.md
e7a776d7-58b6-5c38-a3f3-2c6c8313e64c
docs
python
python_stdtypes
313
93
... lambda mo: mo.group(0).capitalize(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." ``` See also [`istitle()`](#str.istitle "str.istitle"). str.translate(*table*, */*)[¶](#str.translate "Link to this definition") : Re...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
c00c98c0-9195-52d9-9aaf-4a05b0ec42d7
docs
python
python_stdtypes
313
94
[`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_313.md
b02058b1-cf5b-53c8-8c5b-ab0c119a52c1
docs
python
python_stdtypes
313
95
str.zfill(*width*, */*)[¶](#str.zfill "Link to this definition") : 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 ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
652bb0e5-45a7-583b-ad8a-7ccee43a50b7
docs
python
python_stdtypes
313
96
Notably, nested strings, comments, and backslashes are now permitted. An *f-string* (formally a *formatted string literal*) is a string literal that is prefixed with `f` or `F`. This type of string literal allows embedding arbitrary Python expressions within *replacement fields*, which are delimited by curly brackets ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
672869dd-3166-5b21-8368-a4a4e2d7f736
docs
python
python_stdtypes
313
97
To include a literal `{` or `}`, use a double bracket: ```None >>> x = 42 >>> f'{{x}} is {x}' '{x} is 42' ``` Functions can also be used, and [format specifiers](string.html#formatstrings): ```None >>> from math import sqrt >>> f'√2 \N{ALMOST EQUAL TO} {sqrt(2):.5f}' '√2 ≈ 1.41421' ``` Any non-string expression is ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
5167bf9a-1f16-51ca-8918-9e685ca7c8b0
docs
python
python_stdtypes
313
98
While debugging it may be helpful to see both the expression and its value, by using the equals sign (`=`) after the expression. This preserves spaces within the brackets, and can be used with a converter. By default, the debugging operator uses the [`repr()`](functions.html#repr "repr") (`!r`) conversion. For example:...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
9c37dc03-e2e7-5581-b5f9-7bb2848bbbca
docs
python
python_stdtypes
313
99
>>> from fractions import Fraction >>> f'{Fraction(1, 7):.6f}' '0.142857' >>> f'{Fraction(1, 7):_^+10}' '___+1/7___' ``` ### `printf`-style String Formatting[¶](#printf-style-string-formatting "Link to this heading") Note The formatting operations described here exhibit a variety of quirks that lead to a number of c...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b9824ba2-df14-5909-b3d8-6277cbf2708b
docs
python
python_stdtypes
313
100
specifications in *format* are replaced with zero or more elements of *values*. The effect is similar to using the `sprintf()` function in the C language. For example: ```None >>> print('%s has %d quote types.' % ('Python', 2)) Python has 2 quote types. ``` If *format* requires a single argument, *values* may be a si...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
0bd38cdc-1ad5-5de3-9369-3743b3777f24
docs
python
python_stdtypes
313
101
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 specified as `'*'` (an asterisk), the actual precision is read from the next ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
0472b59b-6f92-50d2-a516-13db67b0a9d9
docs
python
python_stdtypes
313
102
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 values. | | `'-'` | The converted value is left adjusted (overrides the `'0'` conversion if both are given)...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
d9fdfcbe-e2bb-5289-82ee-6b3eaada8507
docs
python
python_stdtypes
313
103
| `'X'` | Signed hexadecimal (uppercase). | (2) | | `'e'` | Floating-point exponential format (lowercase). | (3) | | `'E'` | Floating-point exponential format (uppercase). | (3) | | `'f'` | Floating-point decimal format. | (3) | | `'F'` | Floating-point decimal format. | (3) | | `'g'` | Floating-point format. Uses lowe...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
808464fb-0931-56ba-903b-9788070fc85a
docs
python
python_stdtypes
313
104
| `'%'` | 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 form causes a leading `'0x'` or `'0X'` (depending on whether the `'x'` or `'X'` format was used) to ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f29b8511-35c9-5e19-b420-71146caf3ca6
docs
python
python_stdtypes
313
105
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 Sequence Types — [`bytes`](#bytes "bytes"), [`bytearray`](#bytearray "bytearray"), [`memoryview`](#memoryview "memoryview")[¶](#binary-sequ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
507523e6-f549-5172-b740-d39e431d0664
docs
python
python_stdtypes
313
106
### 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 with ASCII compatible data and are closely related to string ob...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
228e65fe-e423-5750-a268-a3f6d8c8bf0b
docs
python
python_stdtypes
313
107
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_313.md
40572320-d875-52f6-af2b-a72ed83bba81
docs
python
python_stdtypes
313
108
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_313.md
e2f38d09-3c8d-5686-9062-1cb96887e62c
docs
python
python_stdtypes
313
109
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(*\**, *...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8eec6e88-db59-5fe8-9ca8-193a6d58c0db
docs
python
python_stdtypes
313
110
```None >>> 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...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
7c88c3d6-10a9-5122-b58e-3973b94cb9e0
docs
python
python_stdtypes
313
111
### Bytearray Objects[¶](#bytearray-objects "Link to this heading") [`bytearray`](#bytearray "bytearray") objects are a mutable counterpart to [`bytes`](#bytes "bytes") objects. *class* bytearray(*source=b''*)[¶](#bytearray "Link to this definition") *class* bytearray(*source*, *encoding*, *errors='strict'*) : The...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
438eb12e-7154-52b9-8064-1884588be08a
docs
python
python_stdtypes
313
112
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 th...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
ed531048-61a6-5f82-bb0f-046d101bf9de
docs
python
python_stdtypes
313
113
hex(*\**, *bytes\_per\_sep=1*)[¶](#bytearray.hex "Link to this definition") hex(*sep*, *bytes\_per\_sep=1*) : Return a string object containing two hexadecimal digits for each byte in the instance. ```None >>> bytearray(b'\xf0\xf1\xf2').hex() 'f0f1f2' ``` ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
507a8270-c248-523f-abc8-24076a232139
docs
python
python_stdtypes
313
114
`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_313.md
ab67de82-7f2e-5219-aecb-835ff6065795
docs
python
python_stdtypes
313
115
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_313.md
fbbf6cab-ac0f-5bdc-84f3-0af02d8c5c3a
docs
python
python_stdtypes
313
116
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_313.md
7d50dcd0-ed9e-53bd-9141-127d751c7435
docs
python
python_stdtypes
313
117
: 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_313.md
683222e1-ad0f-57b7-8478-bddf68a32457
docs
python
python_stdtypes
313
118
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_313.md
2cb435aa-5c0a-5f42-b6ef-d453414d18a2
docs
python
python_stdtypes
313
119
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_313.md
1f2b3388-d8a2-5943-ba48-af9c90e86e67
docs
python
python_stdtypes
313
120
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_313.md
fa4ab0e5-6ed5-5b92-825e-754550b5d29c
docs
python
python_stdtypes
313
121
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 "Lin...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b10d4fc0-348c-5e98-81c5-0a764d1ed6de
docs
python
python_stdtypes
313
122
*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...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
1b8867da-133d-53cd-91a2-873928bbb6e0
docs
python
python_stdtypes
313
123
The separator to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object). bytes.replace(*old*, *new*, *count=-1*, */*)[¶](#bytes.replace "Link to this definition") bytearray.replace(*old*, *new*, *count=-1*, */*)[¶](#bytearray.replace "Link to this definition") : Return a copy of the ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
7b46616f-8886-5fad-9df6-dad3bfc8bdd1
docs
python
python_stdtypes
313
124
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_313.md
2075d131-f7cd-59d8-9563-779d9b7582b7
docs
python
python_stdtypes
313
125
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 by...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e919fda3-ca0e-5616-b981-2e1b3684d1a8
docs
python
python_stdtypes
313
126
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_313.md
ed29b2f9-092e-5ccb-b1af-6eee493dc7c9
docs
python
python_stdtypes
313
127
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_313.md
0b7ca4b0-0648-584a-9a7b-6cf8d6990f0b
docs
python
python_stdtypes
313
128
bytes.ljust(*width*, *fillbyte=b' '*, */*)[¶](#bytes.ljust "Link to this definition") bytearray.ljust(*width*, *fillbyte=b' '*, */*)[¶](#bytearray.ljust "Link to this definition") : Return a copy of the object left justified in a sequence of length *width*. Padding is done using the specified *fillbyte* (defaul...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e0793a6f-572b-5764-92c0-6482f84682dd
docs
python
python_stdtypes
313
129
to removing ASCII whitespace. The *bytes* argument is not a prefix; rather, all combinations of its values are stripped: ```None >>> b' spacious '.lstrip() b'spacious ' >>> b'www.example.com'.lstrip(b'cmowz.') b'example.com' ``` The binary sequence of byte values to remove ma...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f96a9887-c7f6-503e-a93a-9d56a618a2be
docs
python
python_stdtypes
313
130
bytearray.rjust(*width*, *fillbyte=b' '*, */*)[¶](#bytearray.rjust "Link to this definition") : Return a copy of the object right justified in a sequence of length *width*. Padding is done using the specified *fillbyte* (default is an ASCII space). For [`bytes`](#bytes "bytes") objects, the original sequence ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
17c58e36-0d59-56b0-9b99-e9d3b7c27f37
docs
python
python_stdtypes
313
131
Except for splitting from the right, [`rsplit()`](#bytearray.rsplit "bytearray.rsplit") behaves like [`split()`](#bytearray.split "bytearray.split") which is described in detail below. bytes.rstrip(*bytes=None*, */*)[¶](#bytes.rstrip "Link to this definition") bytearray.rstrip(*bytes=None*, */*)[¶](#bytearray...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
035d17de-1a72-56c1-adf2-70cb9ad71130
docs
python
python_stdtypes
313
132
[bytes-like object](../glossary.html#term-bytes-like-object). See [`removesuffix()`](#bytes.removesuffix "bytes.removesuffix") for a method that will remove a single suffix string rather than all of a set of characters. For example: ```None >>> b'Monty Python'.rstrip(b' Python') b'M' >>> b'...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
293e9ca5-8ed4-5d82-a4e2-2459230ddf78
docs
python
python_stdtypes
313
133
limit on the number of splits (all possible splits are made). If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty subsequences (for example, `b'1,,2'.split(b',')` returns `[b'1', b'', b'2']`). The *sep* argument may consist of a multibyte sequence as a...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
802e5824-7bcf-574d-a8d3-1c516d535f2a
docs
python
python_stdtypes
313
134
separator, and the result will contain no empty strings at the start or end if the sequence has leading or trailing whitespace. Consequently, splitting an empty sequence or a sequence consisting solely of ASCII whitespace without a specified separator returns `[]`. For example: ```None >>>...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
fadf3ae6-96c2-53f5-99dd-c79523223e1a
docs
python
python_stdtypes
313
135
```None >>> b' spacious '.strip() b'spacious' >>> b'www.example.com'.strip(b'cmowz.') b'example' ``` The binary sequence of byte values to remove may be any [bytes-like object](../glossary.html#term-bytes-like-object). Note The bytearray version of this method does *not* o...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
26fbf8a8-d0ba-58df-b415-aaf7546aa355
docs
python
python_stdtypes
313
136
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.expandtabs(*tabsize=8*)[¶](#bytes.expandtabs "Link to this definition") bytearray.expandtabs(*tabsize=8*)[¶](#bytearray.expandtabs "Link to this definition") : Re...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f7be3a6f-651a-5456-b24b-d50c2dae6eb4
docs
python
python_stdtypes
313
137
carriage return (`b'\r'`), it is copied and the current column is reset to zero. Any other byte value is copied unchanged and the current column is incremented by one regardless of how the byte value is represented when printed: ```None >>> b'01\t012\t0123\t01234'.expandtabs() b'01 012...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
387732ca-5c0e-52a7-8666-7ecf34700420
docs
python
python_stdtypes
313
138
digits are those byte values in the sequence `b'0123456789'`. For example: ```None >>> b'ABCabc1'.isalnum() True >>> b'ABC abc1'.isalnum() False ``` bytes.isalpha()[¶](#bytes.isalpha "Link to this definition") bytearray.isalpha()[¶](#bytearray.isalpha "Link to this definition") : R...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
d8e870df-675a-5c1e-8a54-0fb8b66716e1
docs
python
python_stdtypes
313
139
bytes.isdigit()[¶](#bytes.isdigit "Link to this definition") bytearray.isdigit()[¶](#bytearray.isdigit "Link to this definition") : Return `True` if all bytes in the sequence are ASCII decimal digits and the sequence is not empty, `False` otherwise. ASCII decimal digits are those byte values in the sequence ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
30940ac7-f1d3-597a-9a23-09cd408e5423
docs
python
python_stdtypes
313
140
are those byte values in the sequence `b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`. bytes.isspace()[¶](#bytes.isspace "Link to this definition") bytearray.isspace()[¶](#bytearray.isspace "Link to this definition") : Return `True` if all bytes in the sequence are ASCII whitespace and the sequence is not empty, `False` ot...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
c37aa006-74f2-5865-b009-371e08df30b8
docs
python
python_stdtypes
313
141
bytearray.isupper()[¶](#bytearray.isupper "Link to this definition") : Return `True` if there is at least one uppercase alphabetic ASCII character in the sequence and no lowercase ASCII characters, `False` otherwise. For example: ```None >>> b'HELLO WORLD'.isupper() True >>> b'Hello world'.i...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
31bf2e81-6244-59ad-bb9c-80db7ec465bc
docs
python
python_stdtypes
313
142
`b'abcdefghijklmnopqrstuvwxyz'`. Uppercase ASCII characters 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.splitlines(*keepends=Fals...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
d10337f2-71a2-50b6-a983-6baae8a709e8
docs
python
python_stdtypes
313
143
Unlike [`split()`](#bytes.split "bytes.split") when a delimiter string *sep* is given, this method returns an empty list for the empty string, and a terminal line break does not result in an extra line: ```None >>> b"".split(b'\n'), b"Two lines\n".split(b'\n') ([b''], [b'Two lines', b'']) >...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
804e5ebc-e78d-5a3b-9d53-dfaa2581256e
docs
python
python_stdtypes
313
144
Unlike [`str.swapcase()`](#str.swapcase "str.swapcase"), it is always the case that `bin.swapcase().swapcase() == bin` for the binary versions. Case conversions are symmetrical in ASCII, even though that is not generally true for arbitrary Unicode code points. Note The bytearray version of thi...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
197da8de-b25d-561f-89ce-522104114c25
docs
python
python_stdtypes
313
145
are those byte values in the sequence `b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`. All other byte values are uncased. The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and p...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3b39dad1-24e6-5e1f-8eec-6dc5d02aed26
docs
python
python_stdtypes
313
146
The bytearray version of this method does *not* operate in place - it always produces a new object, even if no changes were made. bytes.upper()[¶](#bytes.upper "Link to this definition") bytearray.upper()[¶](#bytearray.upper "Link to this definition") : Return a copy of the sequence with all the lowercase A...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e8883074-a2ce-53fa-9511-3323f8316ba2
docs
python
python_stdtypes
313
147
: Return a copy of the sequence left filled with ASCII `b'0'` digits to make a sequence of length *width*. A leading sign prefix (`b'+'`/ `b'-'`) is handled by inserting the padding *after* the sign character rather than before. For [`bytes`](#bytes "bytes") objects, the original sequence is returned ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
8ae51257-edb9-56f1-a05e-83701d2b8b22
docs
python
python_stdtypes
313
148
Bytes objects (`bytes`/`bytearray`) have one unique built-in operation: the `%` operator (modulo). This is also known as the bytes *formatting* or *interpolation* operator. Given `format % values` (where *format* is a bytes object), `%` conversion specifications in *format* are replaced with zero or more elements of *v...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
12961c9d-df22-503e-b186-ee2e329093ff
docs
python
python_stdtypes
313
149
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_313.md
0036479b-cf8c-55bd-8cf8-38900b9e5539
docs
python
python_stdtypes
313
150
... {b'language': b"Python", b"number": 2}) b'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”...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
95030101-21e3-5054-b69e-8dd2de0a650b
docs
python
python_stdtypes
313
151
| `'i'` | Signed integer decimal. | | | `'o'` | Signed octal value. | (1) | | `'u'` | Obsolete type – it is identical to `'d'`. | (8) | | `'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_313.md
2e700fb5-63c9-5f91-bf6f-66afd5aa1875
docs
python
python_stdtypes
313
152
| `'b'` | Bytes (any object that follows the [buffer protocol](../c-api/buffer.html#bufferobjects) or has [`__bytes__()`](../reference/datamodel.html#object.__bytes__ "object.__bytes__")). | (5) | | `'s'` | `'s'` is an alias for `'b'` and should only be used for Python2/3 code bases. | (6) | | `'a'` | Bytes (converts a...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
2bb2ff8c-d02d-5fc6-9c71-4f17a1ca89d6
docs
python
python_stdtypes
313
153
The precision determines the number of digits after the decimal point and defaults to 6. 4. The alternate form causes the result to always contain a decimal point, and trailing zeroes are not removed as they would otherwise be. The precision determines the number of significant digits before and after the ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
5e4b2862-1137-55b9-89ff-fc06f34976f5
docs
python
python_stdtypes
313
154
### Memory Views[¶](#memory-views "Link to this heading") [`memoryview`](#memoryview "memoryview") objects allow Python code to access the internal data of an object that supports the [buffer protocol](../c-api/buffer.html#bufferobjects) without copying. *class* memoryview(*object*)[¶](#memoryview "Link to this defin...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
80ccac3d-1bcd-51b3-ad67-b8cb2cdd5149
docs
python
python_stdtypes
313
155
`len(view)` is equal to the length of [`tolist`](#memoryview.tolist "memoryview.tolist"), which is the nested list representation of the view. If `view.ndim = 1`, this is equal to the number of elements in the view. Changed in version 3.12: If `view.ndim == 0`, `len(view)` now raises [`TypeError`](exce...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b10aecd9-4ebf-55d5-ad21-31b372c4a524
docs
python
python_stdtypes
313
156
from the [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") module, indexing with an integer or a tuple of integers is also supported and returns a single *element* with the correct type. One-dimensional memoryviews can be indexed with an integer or a one-integer tupl...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
60652023-7b53-53af-8b90-69dea355d201
docs
python
python_stdtypes
313
157
>>> v = memoryview(data) >>> v.readonly False >>> v[0] = ord(b'z') >>> data bytearray(b'zbcefg') >>> v[1:4] = b'123' >>> data bytearray(b'z123fg') >>> v[2:3] = b'spam' Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: memoryview assi...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
192b931b-3bcc-5406-8cc7-4e7714895d33
docs
python
python_stdtypes
313
158
One-dimensional memoryviews with formats ‘B’, ‘b’ or ‘c’ are now [hashable](../glossary.html#term-hashable). Changed in version 3.4: memoryview is now registered automatically with [`collections.abc.Sequence`](collections.abc.html#collections.abc.Sequence "collections.abc.Sequence") Changed in version...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
433a86ac-96ad-554b-9bc4-9bfbcb123448
docs
python
python_stdtypes
313
159
[`tolist()`](#memoryview.tolist "memoryview.tolist"), `v` and `w` are equal if `v.tolist() == w.tolist()`: ```None >>> import array >>> a = array.array('I', [1, 2, 3, 4, 5]) >>> b = array.array('d', [1.0, 2.0, 3.0, 4.0, 5.0]) >>> c = array.array('b', [5, 3, 1]) >...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
ed66eeb6-4648-565b-a779-fa2aba4d6550
docs
python
python_stdtypes
313
160
... _fields_ = [("x", c_long), ("y", c_long)] ... >>> point = BEPoint(100, 200) >>> a = memoryview(point) >>> b = memoryview(point) >>> a == point False >>> a == b False ``` Note that, as with floating-point numbers, `v is w` d...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
44ead0d8-6791-5edc-9b99-d8d51603abf7
docs
python
python_stdtypes
313
161
representation with all elements converted to bytes. [`tobytes()`](#memoryview.tobytes "memoryview.tobytes") supports all format strings, including those that are not in [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") module syntax. Added in versio...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
5ed229b2-b6fd-5bf6-bc15-c34395bf0652
docs
python
python_stdtypes
313
162
``` Added in version 3.5. Changed in version 3.8: Similar to [`bytes.hex()`](#bytes.hex "bytes.hex"), [`memoryview.hex()`](#memoryview.hex "memoryview.hex") now supports optional *sep* and *bytes\_per\_sep* parameters to insert separators between bytes in the hex output. t...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
73ab198a-ab02-5c98-8dc1-538b760212dd
docs
python
python_stdtypes
313
163
toreadonly()[¶](#memoryview.toreadonly "Link to this definition") : Return a readonly version of the memoryview object. The original memoryview object is unchanged. ```None >>> m = memoryview(bytearray(b'abc')) >>> mm = m.toreadonly() >>> mm.tolist() [97, 98, 9...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
c370c7a1-6b62-5c2e-8542-9e1886b6a223
docs
python
python_stdtypes
313
164
dangling resources) as soon as possible. After this method has been called, any further operation on the view raises a [`ValueError`](exceptions.html#ValueError "ValueError") (except [`release()`](#memoryview.release "memoryview.release") itself which can be called multiple times): ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
d47459ad-aaef-50fb-8cf6-b7ca5994120f
docs
python
python_stdtypes
313
165
cast(*format*, */*)[¶](#memoryview.cast "Link to this definition") cast(*format*, *shape*, */*) : Cast a memoryview to a new format or shape. *shape* defaults to `[byte_length//new_itemsize]`, which means that the result view will be one-dimensional. The return value is a new memoryview, ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f634da65-8572-56d2-8d7a-b1bf29385f94
docs
python
python_stdtypes
313
166
>>> x = memoryview(a) >>> x.format 'l' >>> x.itemsize 8 >>> len(x) 3 >>> x.nbytes 24 >>> y = x.cast('B') >>> y.format 'B' >>> y.itemsize 1 >>> len(y) 24 >>> y.nbytes 24 ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
16bcace1-a130-5031-82cf-df7a4a784078
docs
python
python_stdtypes
313
167
'i' >>> y.itemsize 4 >>> len(y) 2 >>> y.nbytes 48 >>> z = y.cast('b') >>> z.format 'b' >>> z.itemsize 1 >>> len(z) 48 >>> z.nbytes 48 ``` Cast 1D/unsigned long to 2D/unsigned ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
2b3ead81-ab81-5949-884b-15697ff28f1e
docs
python
python_stdtypes
313
168
Added in version 3.3. nbytes[¶](#memoryview.nbytes "Link to this definition") : `nbytes == product(shape) * itemsize == len(m.tobytes())`. This is the amount of space in bytes that the array would use in a contiguous representation. It is not necessarily equal to `len(m)`: `...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
eebde2a7-1688-5071-9a6d-b9b3fd60d2fa
docs
python
python_stdtypes
313
169
Added in version 3.3. readonly[¶](#memoryview.readonly "Link to this definition") : A bool indicating whether the memory is read only. format[¶](#memoryview.format "Link to this definition") : A string containing the format (in [`struct`](struct.html#module-struct "struct: Interpret bytes ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
544175c6-28df-5f96-bccf-6866686b244c
docs
python
python_stdtypes
313
170
>>> m.itemsize 2 >>> m[0] 32000 >>> struct.calcsize('H') == m.itemsize True ``` ndim[¶](#memoryview.ndim "Link to this definition") : An integer indicating how many dimensions of a multi-dimensional array the memory represents. shape[¶](#me...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
a8626bf5-879e-56a4-b03b-c54652c96718
docs
python
python_stdtypes
313
171
: Used internally for PIL-style arrays. The value is informational only. c\_contiguous[¶](#memoryview.c_contiguous "Link to this definition") : A bool indicating whether the memory is C-[contiguous](../glossary.html#term-contiguous). Added in version 3.3. f\_contiguous[¶](#memoryview.f_co...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
4f65b2ca-65ad-545b-8913-c9199279c31b
docs
python
python_stdtypes
313
172
computing mathematical operations such as intersection, union, difference, and symmetric difference. (For other containers see the built-in [`dict`](#dict "dict"), [`list`](#list "list"), and [`tuple`](#tuple "tuple") classes, and the [`collections`](collections.html#module-collections "collections: Container datatypes...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
0cccf32c-4ba8-5fd4-a721-36df080ad349
docs
python
python_stdtypes
313
173
another set. The [`frozenset`](#frozenset "frozenset") type is immutable and [hashable](../glossary.html#term-hashable) — its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set. Non-empty sets (not frozensets) can be created by placing a comma-s...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
5062a47d-6f22-5c67-a5d4-9ab3f96d92ae
docs
python
python_stdtypes
313
174
* Use a comma-separated list of elements within braces: `{'jack', 'sjoerd'}` * Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}` * Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])` Instances of [`set`](#set "set") and [`frozenset`](#frozenset "frozenset") provide the fo...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
5e5bfb2c-2f18-5898-b321-390709fb9244
docs
python
python_stdtypes
313
175
: Test whether every element in the set is in *other*. set < other : Test whether the set is a proper subset of *other*, that is, `set <= other and set != other`. frozenset.issuperset(*other*, */*)[¶](#frozenset.issuperset "Link to this definition") set.issuperset(*other*, */*)[¶](#set.issuperset "Link to th...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3d909eac-18c8-571c-bb92-ad70c74582f4
docs
python
python_stdtypes
313
176
frozenset.difference(*\*others*)[¶](#frozenset.difference "Link to this definition") set.difference(*\*others*)[¶](#set.difference "Link to this definition") set - other - ... : Return a new set with elements in the set that are not in the others. frozenset.symmetric\_difference(*other*, */*)[¶](#frozenset.symmetr...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
9f6b8875-785d-5ebf-9a6b-6a02a7b25642
docs
python
python_stdtypes
313
177
[`intersection()`](#frozenset.intersection "frozenset.intersection"), [`difference()`](#frozenset.difference "frozenset.difference"), [`symmetric_difference()`](#frozenset.symmetric_difference "frozenset.symmetric_difference"), [`issubset()`](#frozenset.issubset "frozenset.issubset"), and [`issuperset()`](#frozenset.is...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e03cdc43-f2ef-58bf-b59b-47bdc18b54ec
docs
python
python_stdtypes
313
178
is not equal). A set is greater than another set if and only if the first set is a proper superset of the second set (is a superset, but is not equal). Instances of [`set`](#set "set") are compared to instances of [`frozenset`](#frozenset "frozenset") based on their members. For example, `set('abc') == frozenset('abc'...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
e67467df-23d7-5155-a7f3-1a95d4e05ccc
docs
python
python_stdtypes
313
179
return the type of the first operand. For example: `frozenset('ab') | set('bc')` returns an instance of [`frozenset`](#frozenset "frozenset"). The following table lists operations available for [`set`](#set "set") that do not apply to immutable instances of [`frozenset`](#frozenset "frozenset"): set.update(*\*others*...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
fed6a85c-99c4-5269-b5ab-7cf4fbc91c47
docs
python
python_stdtypes
313
180
set.add(*elem*, */*)[¶](#set.add "Link to this definition") : Add element *elem* to the set. set.remove(*elem*, */*)[¶](#set.remove "Link to this definition") : Remove element *elem* from the set. Raises [`KeyError`](exceptions.html#KeyError "KeyError") if *elem* is not contained in the set. set.discard(*elem...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
912df4e3-995e-57e5-9cc4-55b5b8f411bf
docs
python
python_stdtypes
313
181
[`symmetric_difference_update()`](#set.symmetric_difference_update "set.symmetric_difference_update") methods will accept any iterable as an argument. Note, the *elem* argument to the [`__contains__()`](../reference/datamodel.html#object.__contains__ "object.__contains__"), [`remove()`](#set.remove "set.remove"), and ...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b043d2a2-8a36-524c-9d39-f89aa0aabfb9
docs
python
python_stdtypes
313
182
A dictionary’s keys are *almost* arbitrary values. Values that are not [hashable](../glossary.html#term-hashable), that is, values containing lists, dictionaries or other mutable types (that are compared by value rather than by object identity) may not be used as keys. Values that compare equal (such as `1`, `1.0`, and...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
30965019-1f07-5970-a4aa-96a9d28ecf13
docs
python
python_stdtypes
313
183
`dict([('foo', 100), ('bar', 200)])`, `dict(foo=100, bar=200)` If no positional argument is given, an empty dictionary is created. If a positional argument is given and it defines a `keys()` method, a dictionary is created by calling [`__getitem__()`](../reference/datamodel.html#object.__getitem__ "o...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
3da45b26-02d9-59e8-b00e-7cd1d13b0779
docs
python
python_stdtypes
313
184
being added is already present, the value from the keyword argument replaces the value from the positional argument. Dictionaries compare equal if and only if they have the same `(key, value)` pairs (regardless of ordering). Order comparisons (‘<’, ‘<=’, ‘>=’, ‘>’) raise [`TypeError`](exceptions.ht...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
f099ef44-a500-521c-8fae-9cfa4f7df166
docs
python
python_stdtypes
313
185
Dictionaries preserve insertion order. Note that updating a key does not affect the order. Keys added after deletion are inserted at the end. ```None >>> d = {"one": 1, "two": 2, "three": 3, "four": 4} >>> d {'one': 1, 'two': 2, 'three': 3, 'four': 4} >>> list(d) ['one', 'two', 'three',...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
b0671d4f-7e0c-5142-a8fc-87d4572074ed
docs
python
python_stdtypes
313
186
: Return the item of *d* with key *key*. Raises a [`KeyError`](exceptions.html#KeyError "KeyError") if *key* is not in the map. If a subclass of dict defines a method [`__missing__()`](../reference/datamodel.html#object.__missing__ "object.__missing__") and *key* is not present, the `d[ke...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
06902f7f-a3e0-5005-b5eb-32ef6fa4fc2b
docs
python
python_stdtypes
313
187
... def __missing__(self, key): ... return 0 ... >>> c = Counter() >>> c['red'] 0 >>> c['red'] += 1 >>> c['red'] 1 ``` The example above shows part of the implementation of [`collections.Counter`](collections.ht...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
68f490ac-0197-5e83-866c-11e1335c9c66
docs
python
python_stdtypes
313
188
clear()[¶](#dict.clear "Link to this definition") : Remove all items from the dictionary. copy()[¶](#dict.copy "Link to this definition") : Return a shallow copy of the dictionary. *classmethod* fromkeys(*iterable*, *value=None*, */*)[¶](#dict.fromkeys "Link to this definition") : Create...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
7fee1a35-71f0-5eff-98e1-fbc19286eff2
docs
python
python_stdtypes
313
189
If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](exceptions.html#KeyError "KeyError"). items()[¶](#dict.items "Link to this definition") : Return a new view of the dictionary’s items (`(key, value)` pairs). See the [documentation of vie...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
aeb3e924-0b48-50d8-8190-8eda4e791cad
docs
python
python_stdtypes
313
190
[`popitem()`](#dict.popitem "dict.popitem") is useful to destructively iterate over a dictionary, as often used in set algorithms. If the dictionary is empty, calling [`popitem()`](#dict.popitem "dict.popitem") raises a [`KeyError`](exceptions.html#KeyError "KeyError"). Changed in versi...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md
89ef6292-8e8a-5bb8-9427-13f89d7857d1
docs
python
python_stdtypes
313
191
update(*iterable*, */*, *\*\*kwargs*) : Update the dictionary with the key/value pairs from *mapping* or *iterable* and *kwargs*, overwriting existing keys. Return `None`. [`update()`](#dict.update "dict.update") accepts either another object with a `keys()` method (in which case [`__...
large_dataset/raw/docs/python/stdtypes/stdtypes_313.md