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 |
|---|---|---|---|---|---|---|---|
4406b8d1-1c25-51e8-a847-e53871ab11c9 | docs | python | python_stdtypes | 312 | 116 | bytes.ljust(*width*[, *fillbyte*])[¶](#bytes.ljust "Link to this definition")
bytearray.ljust(*width*[, *fillbyte*])[¶](#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* (default is an ASCII
... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
cce1c2eb-0f15-5c48-9158-e3a6753ee610 | docs | python | python_stdtypes | 312 | 117 | ASCII characters. If omitted or `None`, the *chars* argument defaults
to removing ASCII whitespace. The *chars* 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... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
d7901794-830d-58e9-b370-0675af90292d | docs | python | python_stdtypes | 312 | 118 | bytearray.rjust(*width*[, *fillbyte*])[¶](#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 is retur... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
5fb24283-adee-51d4-b560-43250a8d626c | docs | python | python_stdtypes | 312 | 119 | 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([*chars*])[¶](#bytes.rstrip "Link to this definition")
bytearray.rstrip([*chars*])[¶](#bytearray.rstrip "Link to... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
4161286b-dfb9-5bf5-87a8-4e8e9d350d58 | docs | python | python_stdtypes | 312 | 120 | [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_312.md |
f250800c-3aeb-50ed-8a37-929a93ac99ec | docs | python | python_stdtypes | 312 | 121 | 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_312.md |
066ada65-9de5-5d3e-a0b9-7c71e8d83ffa | docs | python | python_stdtypes | 312 | 122 | 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_312.md |
23b12814-930d-5b02-bf8a-61038b686ed9 | docs | python | python_stdtypes | 312 | 123 | not a prefix or suffix; rather, all combinations of its values are
stripped:
```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#ter... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
38532b19-2640-5289-a710-d64c6de1227b | docs | python | python_stdtypes | 312 | 124 | character, and the first byte capitalized and the rest lowercased.
Non-ASCII byte values are passed through unchanged.
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.exp... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
9665dccb-e924-59c4-a2ed-5cb71524610f | docs | python | python_stdtypes | 312 | 125 | is equal to the next tab position. (The tab character itself is not
copied.) If the current byte is an ASCII newline (`b'\n'`) or
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 reg... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
c0597b6c-8515-5db7-9d81-7594d84cf993 | docs | python | python_stdtypes | 312 | 126 | Alphabetic ASCII characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'`. ASCII decimal
digits are those byte values in the sequence `b'0123456789'`.
For example:
```None
>>> b'ABCabc1'.isalnum()
True
>>> b'ABC abc1'.isalnum()
Fals... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
b9df6066-a0eb-562b-93cc-5e47edac7bf0 | docs | python | python_stdtypes | 312 | 127 | : Return `True` if the sequence is empty or all bytes in the sequence are ASCII,
`False` otherwise.
ASCII bytes are in the range 0-0x7F.
Added in version 3.7.
bytes.isdigit()[¶](#bytes.isdigit "Link to this definition")
bytearray.isdigit()[¶](#bytearray.isdigit "Link to this definition")
: Return `Tr... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
c89fa54a-ebd9-5cf7-9073-32a319572296 | docs | python | python_stdtypes | 312 | 128 | Lowercase ASCII characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyz'`. Uppercase ASCII characters
are those byte values in the sequence `b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`.
bytes.isspace()[¶](#bytes.isspace "Link to this definition")
bytearray.isspace()[¶](#bytearray.isspace "Link t... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
61ca4923-f11c-5984-a7cf-6cada3eff352 | docs | python | python_stdtypes | 312 | 129 | >>> b'Hello World'.istitle()
True
>>> b'Hello world'.istitle()
False
```
bytes.isupper()[¶](#bytes.isupper "Link to this definition")
bytearray.isupper()[¶](#bytearray.isupper "Link to this definition")
: Return `True` if there is at least one uppercase alphabetic ASCII character
in the sequ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
bb90777e-42eb-5b36-b8bd-7d48645cc900 | docs | python | python_stdtypes | 312 | 130 | >>> b'Hello World'.lower()
b'hello world'
```
Lowercase ASCII characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyz'`. Uppercase ASCII characters
are those byte values in the sequence `b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`.
Note
The bytearray version of this method d... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
3efe3f26-250f-5a10-9f68-a05f048e3d5d | docs | python | python_stdtypes | 312 | 131 | >>> b'ab c\n\nde fg\rkl\r\n'.splitlines(keepends=True)
[b'ab c\n', b'\n', b'de fg\r', b'kl\r\n']
```
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 ext... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
9d4ac235-2fc0-5163-94bb-f0a24db91064 | docs | python | python_stdtypes | 312 | 132 | are those byte values in the sequence `b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`.
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 fo... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
78b4ca05-ca19-53c1-9c19-c2b349e40f3a | docs | python | python_stdtypes | 312 | 133 | `b'abcdefghijklmnopqrstuvwxyz'`. Uppercase ASCII characters
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 ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
1e180367-e4a9-5acc-9ff8-e61f780c0716 | docs | python | python_stdtypes | 312 | 134 | 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_312.md |
84fc9530-93dc-5d69-a23d-b13c32c36607 | docs | python | python_stdtypes | 312 | 135 | : 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_312.md |
ee323dd0-77d9-58f1-8ae7-1ace90eea692 | docs | python | python_stdtypes | 312 | 136 | 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_312.md |
0730acca-7be8-5f08-a8c3-e708a0c03678 | docs | python | python_stdtypes | 312 | 137 | 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_312.md |
5933b256-5db0-5eea-a98a-76ec11730ff7 | docs | python | python_stdtypes | 312 | 138 | ... {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_312.md |
ff190760-7329-55b8-9f6c-c2f9dc4e5315 | docs | python | python_stdtypes | 312 | 139 | | `'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_312.md |
a9376750-5afe-533d-91c9-bd1e8a73d9b1 | docs | python | python_stdtypes | 312 | 140 | | `'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_312.md |
5ea1d7bc-0924-5176-88fa-d4a85ac55bb3 | docs | python | python_stdtypes | 312 | 141 | 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_312.md |
4592b5b8-138e-5495-9912-3730083dca09 | docs | python | python_stdtypes | 312 | 142 | ### 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_312.md |
5d131250-59de-5a9c-a9e7-5cfdad474124 | docs | python | python_stdtypes | 312 | 143 | `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_312.md |
c9828ead-de35-5256-8381-15368818979d | docs | python | python_stdtypes | 312 | 144 | 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_312.md |
a68ae78a-334c-53f3-a20f-fbd74f646661 | docs | python | python_stdtypes | 312 | 145 | >>> 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_312.md |
5307e598-7c42-5113-8b16-70d8aa30ea42 | docs | python | python_stdtypes | 312 | 146 | 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_312.md |
0a2e2fa5-30e7-5ecd-af36-143ed103d502 | docs | python | python_stdtypes | 312 | 147 | [`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_312.md |
d095cbba-cd68-53b6-8553-157767106a88 | docs | python | python_stdtypes | 312 | 148 | ... _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_312.md |
a5cd4305-af5e-55cf-aba8-01278de9a2a9 | docs | python | python_stdtypes | 312 | 149 | 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_312.md |
0226314b-ad67-5cde-a12c-d3478000207c | docs | python | python_stdtypes | 312 | 150 | 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.
tolist()[¶](#m... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
b58df36d-5410-5226-89ac-162b8170968a | docs | python | python_stdtypes | 312 | 151 | 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_312.md |
80df89a8-5457-56f1-9d59-953b0eb5a6a3 | docs | python | python_stdtypes | 312 | 152 | 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_312.md |
85135a0f-1b03-5fe2-aee8-62a8fd2c313c | docs | python | python_stdtypes | 312 | 153 | cast(*format*[, *shape*])[¶](#memoryview.cast "Link to this definition")
: 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, but
the buffer itsel... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
eb563696-67e4-5426-ac24-15178bd6a07d | docs | python | python_stdtypes | 312 | 154 | >>> 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
```
Cast 1D/unsigned... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
63d4296d-a3b1-5415-a24d-0b0df857ad54 | docs | python | python_stdtypes | 312 | 155 | >>> 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 long:
... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
d97df7d2-08e0-5dd8-805c-6640efaf85e9 | docs | python | python_stdtypes | 312 | 156 | 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_312.md |
3bcf00be-2504-5267-aaf5-28f526e3292b | docs | python | python_stdtypes | 312 | 157 | 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_312.md |
7644dfae-4b53-524d-b8c1-6970dea8a742 | docs | python | python_stdtypes | 312 | 158 | >>> 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_312.md |
e4d8a644-8149-5e02-8e8b-8c2c1e309a82 | docs | python | python_stdtypes | 312 | 159 | : 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_312.md |
44ffd36f-0ccf-597c-97ad-387ce26b63a3 | docs | python | python_stdtypes | 312 | 160 | 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_312.md |
8f8ed8a7-c78d-58ee-8a8d-28cb77ae8eff | docs | python | python_stdtypes | 312 | 161 | 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_312.md |
99e3b7e6-fb39-53a2-8b5e-5680e5cfd626 | docs | python | python_stdtypes | 312 | 162 | * 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"... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
76b8035f-8270-52dd-8d93-b2d9c23b16bd | docs | python | python_stdtypes | 312 | 163 | `set <= other and set != other`.
issuperset(*other*)[¶](#frozenset.issuperset "Link to this definition")
set >= other
: Test whether every element in *other* is in the set.
set > other
: Test whether the set is a proper superset of *other*, that is, `set >=
other and set != ot... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
a261e9bb-ac28-583c-bba1-58d2d592cc96 | docs | python | python_stdtypes | 312 | 164 | : Return a new set with elements in either the set or *other* but not both.
copy()[¶](#frozenset.copy "Link to this definition")
: Return a shallow copy of the set.
Note, the non-operator versions of [`union()`](#frozenset.union "frozenset.union"), [`intersection()`](#frozenset.intersection "froze... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
75b21c42-4c83-533a-901b-c21a916ea589 | docs | python | python_stdtypes | 312 | 165 | sets are equal if and only if every element of each set is contained in the
other (each is a subset of the other). A set is less than another set if and
only if the first set is a proper subset of the second set (is a subset, but
is not equal). A set is greater than another set if and only if the first ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
551b0dcb-92e1-5d5c-9f21-1f80132b2d6e | docs | python | python_stdtypes | 312 | 166 | the [`list.sort()`](#list.sort "list.sort") method is undefined for lists of sets.
Set elements, like dictionary keys, must be [hashable](../glossary.html#term-hashable).
Binary operations that mix [`set`](#set "set") instances with [`frozenset`](#frozenset "frozenset")
return the type of the first op... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
7a9be53a-8d6d-5d9f-aa76-24fd9ec2bf52 | docs | python | python_stdtypes | 312 | 167 | difference\_update(*\*others*)[¶](#frozenset.difference_update "Link to this definition")
set -= other | ...
: Update the set, removing elements found in others.
symmetric\_difference\_update(*other*)[¶](#frozenset.symmetric_difference_update "Link to this definition")
set ^= other
: Upda... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
edbb356b-f25c-5b43-85ed-f00db08195b1 | docs | python | python_stdtypes | 312 | 168 | [`KeyError`](exceptions.html#KeyError "KeyError") if the set is empty.
clear()[¶](#frozenset.clear "Link to this definition")
: Remove all elements from the set.
Note, the non-operator versions of the [`update()`](#frozenset.update "frozenset.update"),
[`intersection_update()`](#frozenset.in... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
9b965c43-8af1-59a9-a09a-ec7170cc2b09 | docs | python | python_stdtypes | 312 | 169 | ## Mapping Types — [`dict`](#dict "dict")[¶](#mapping-types-dict "Link to this heading")
A [mapping](../glossary.html#term-mapping) object maps [hashable](../glossary.html#term-hashable) values to arbitrary objects.
Mappings are mutable objects. There is currently only one standard mapping
type, the *dictionary*. (For... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
09f36c4f-f998-5823-9867-04278bdfa9c1 | docs | python | python_stdtypes | 312 | 170 | *class* dict(*mapping*, *\*\*kwargs*)
*class* dict(*iterable*, *\*\*kwargs*)
: Return a new dictionary initialized from an optional positional argument
and a possibly empty set of keyword arguments.
Dictionaries can be created by several means:
* Use a comma-separated list of `key: value` pairs within ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
33319419-04a5-50b4-9dd6-4e7114986f57 | docs | python | python_stdtypes | 312 | 171 | [iterable](../glossary.html#term-iterable) object. Each item in the iterable must itself be an iterable
with exactly two elements. The first element of each item becomes a key in the
new dictionary, and the second element the corresponding value. If a key occurs
more than once, the last value for that k... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
4a2f44bf-3977-51c1-8de6-d731e331006d | docs | python | python_stdtypes | 312 | 172 | >>> e = dict({'three': 3, 'one': 1, 'two': 2})
>>> f = dict({'one': 1, 'three': 3}, two=2)
>>> a == b == c == d == e == f
True
```
Providing keyword arguments as in the first example only works for keys that
are valid Python identifiers. Otherwise, any valid keys can be used.
These are... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
00597755-37fa-5386-8874-e90cd363c951 | docs | python | python_stdtypes | 312 | 173 | No other operations or methods invoke `__missing__()`. If
`__missing__()` is not defined, [`KeyError`](exceptions.html#KeyError "KeyError") is raised.
`__missing__()` must be a method; it cannot be an instance variable:
```None
>>> class Counter(dict):
... def __miss... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
7e2de6c8-9a2d-5bd3-b58e-0e39a1040614 | docs | python | python_stdtypes | 312 | 174 | : Return `True` if *d* has a key *key*, else `False`.
key not in d
: Equivalent to `not key in d`.
iter(d)
: Return an iterator over the keys of the dictionary. This is a shortcut
for `iter(d.keys())`.
clear()[¶](#dict.clear "Link to this definition")
: Remove all items fr... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
cb332718-4db1-5538-ab10-34124b7d6fda | docs | python | python_stdtypes | 312 | 175 | comprehension](../reference/expressions.html#dict) instead.
get(*key*, *default=None*, */*)[¶](#dict.get "Link to this definition")
: Return the value for *key* if *key* is in the dictionary, else *default*.
If *default* is not given, it defaults to `None`, so that this method
never r... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
bdfd2448-601d-5d8d-9cf8-6f2275fd2585 | docs | python | python_stdtypes | 312 | 176 | a [`KeyError`](exceptions.html#KeyError "KeyError") is raised.
popitem()[¶](#dict.popitem "Link to this definition")
: Remove and return a `(key, value)` pair from the dictionary.
Pairs are returned in LIFO order.
[`popitem()`](#dict.popitem "dict.popitem") is useful to destructively... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
5b8d3855-57a9-5b02-bcd8-0ec20ab45d37 | docs | python | python_stdtypes | 312 | 177 | : If *key* is in the dictionary, return its value. If not, insert *key*
with a value of *default* and return *default*. *default* defaults to
`None`.
update([*other*])[¶](#dict.update "Link to this definition")
: Update the dictionary with the key/value pairs from *other*, overwriting
... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
97d7a912-ce3a-550c-8c83-a3d86bb98786 | docs | python | python_stdtypes | 312 | 178 | An equality comparison between one `dict.values()` view and another
will always return `False`. This also applies when comparing
`dict.values()` to itself:
```None
>>> d = {'a': 1}
>>> d.values() == d.values()
False
```
d | other
: Create a new... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
7e81ac31-2e2b-5d2b-b558-d6c1bafe9220 | docs | python | python_stdtypes | 312 | 179 | value)` pairs (regardless of ordering). Order comparisons (‘<’, ‘<=’, ‘>=’, ‘>’) raise
[`TypeError`](exceptions.html#TypeError "TypeError").
Dictionaries preserve insertion order. Note that updating a key does not
affect the order. Keys added after deletion are inserted at the end.
```None
>>>... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
ae750c77-cfc9-5628-b02b-1f1e7a25fb05 | docs | python | python_stdtypes | 312 | 180 | {'one': 1, 'two': 2, 'three': 3, 'four': 4}
>>> list(reversed(d))
['four', 'three', 'two', 'one']
>>> list(reversed(d.values()))
[4, 3, 2, 1]
>>> list(reversed(d.items()))
[('four', 4), ('three', 3), ('two', 2), ('one', 1)]
```
Changed in version 3.8: Dictionaries are now reversible... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
e289d337-9b5b-5e87-9fe8-0363955533e2 | docs | python | python_stdtypes | 312 | 181 | : Return the number of entries in the dictionary.
iter(dictview)
: Return an iterator over the keys, values or items (represented as tuples of
`(key, value)`) in the dictionary.
Keys and values are iterated over in insertion order.
This allows the creation of `(value, key)` pairs
using [`zip()`](f... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
55c241ba-c73e-5818-80df-fc91741b3457 | docs | python | python_stdtypes | 312 | 182 | The view will be iterated in reverse order of the insertion.
Changed in version 3.8: Dictionary views are now reversible.
dictview.mapping
: Return a [`types.MappingProxyType`](types.html#types.MappingProxyType "types.MappingProxyType") that wraps the original
dictionary to which the view refers.
A... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
632c4655-e01a-52b5-8091-c1765be080b4 | docs | python | python_stdtypes | 312 | 183 | set-like views accept any iterable as the other operand,
unlike sets which only accept sets as the input.
An example of dictionary view usage:
```None
>>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
>>> keys = dishes.keys()
>>> values = dishes.values()
>>> # iteration
>>> n = 0
>>> for val in values:... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
3139717d-2194-5d4f-a9f5-96d2eaef4d9c | docs | python | python_stdtypes | 312 | 184 | >>> values.mapping['spam']
500
```
## Context Manager Types[¶](#context-manager-types "Link to this heading")
Python’s [`with`](../reference/compound_stmts.html#with) statement supports the concept of a runtime context
defined by a context manager. This is implemented using a pair of methods
that allow user-defined c... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
8551ec62-798d-55ea-b284-49373f7bb6ca | docs | python | python_stdtypes | 312 | 185 | File objects return themselves from \_\_enter\_\_() to allow [`open()`](functions.html#open "open") to be
used as the context expression in a [`with`](../reference/compound_stmts.html#with) statement.
An example of a context manager that returns a related object is the one
returned by [`decimal.localco... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
ad3c1ab8-4c1d-5a88-9145-d6d57a3fdbf0 | docs | python | python_stdtypes | 312 | 186 | body of the [`with`](../reference/compound_stmts.html#with) statement, the arguments contain the exception type,
value and traceback information. Otherwise, all three arguments are `None`.
Returning a true value from this method will cause the [`with`](../reference/compound_stmts.html#with) statement
t... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
e43c3cc0-6f73-56f2-8f72-22e7ca14d18c | docs | python | python_stdtypes | 312 | 187 | context management code to easily detect whether or not an [`__exit__()`](../reference/datamodel.html#object.__exit__ "object.__exit__")
method has actually failed.
Python defines several context managers to support easy thread synchronisation,
prompt closure of files or other objects, and simpler manipulation... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
8c55f527-17c0-5da1-aace-7e5ba7b3bd36 | docs | python | python_stdtypes | 312 | 188 | context manager implementing the necessary [`__enter__()`](#contextmanager.__enter__ "contextmanager.__enter__") and
[`__exit__()`](#contextmanager.__exit__ "contextmanager.__exit__") methods, rather than the iterator produced by an
undecorated generator function.
Note that there is no specific slot for any of these m... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
73b1c674-ed4a-5566-80e3-4634fcb83c7b | docs | python | python_stdtypes | 312 | 189 | ### Generic Alias Type[¶](#generic-alias-type "Link to this heading")
`GenericAlias` objects are generally created by
[subscripting](../reference/expressions.html#subscriptions) a class. They are most often used with
[container classes](../reference/datamodel.html#sequence-types), such as [`list`](#list "list") or
[`d... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
f51cace5-f9c1-5fa2-ae87-667776954dd4 | docs | python | python_stdtypes | 312 | 190 | argument(s) supplied to a [subscription](../reference/expressions.html#subscriptions) of the class may
indicate the type(s) of the elements an object contains. For example,
`set[bytes]` can be used in type annotations to signify a [`set`](#set "set") in
which all the elements are of type [`bytes`](#bytes "bytes").
For... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
3e509bae-6e9d-5ca6-baa0-88021796bccc | docs | python | python_stdtypes | 312 | 191 | represent this kind of object in type annotations with the `GenericAlias`
`re.Match[str]`.
* If `y = re.search(b'bar', b'bar')`, (note the `b` for [`bytes`](#bytes "bytes")),
`y` will also be an instance of `re.Match`, but the return
values of `y.group(0)` and `y[0]` will both be of type
[`bytes`](#bytes "byt... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
f3b9f8dc-e8ca-50f2-8eb7-c38bcb3d69fb | docs | python | python_stdtypes | 312 | 192 | Another example for [mapping](../glossary.html#term-mapping) objects, using a [`dict`](#dict "dict"), which
is a generic type expecting two type parameters representing the key type
and the value type. In this example, the function expects a `dict` with
keys of type [`str`](#str "str") and values of typ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
893e9f95-0be9-56c3-a8f0-66be2b287dc9 | docs | python | python_stdtypes | 312 | 193 | a container object from a `GenericAlias`, the elements in the container are not checked
against their type. For example, the following code is discouraged, but will
run without errors:
```None
>>> t = list[str]
>>> t([1, 2, 3])
[1, 2, 3]
```
Furthermore, parameterized generics erase type parameters during object
crea... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
e3420b9a-d86b-5f03-bcb2-c3ed9eaa6d7d | docs | python | python_stdtypes | 312 | 194 | used. The index must have as many elements as there are type variable items
in the `GenericAlias` object’s [`__args__`](#genericalias.__args__ "genericalias.__args__").
```None
>>> from typing import TypeVar
>>> Y = TypeVar('Y')
>>> dict[str, Y][int]
dict[str, int]
```
#### Standard Generic Classes[¶](#standard-gener... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
f62712c5-0cc5-5868-9d75-010e380bcc2c | docs | python | python_stdtypes | 312 | 195 | * [`collections.OrderedDict`](collections.html#collections.OrderedDict "collections.OrderedDict")
* [`collections.Counter`](collections.html#collections.Counter "collections.Counter")
* [`collections.ChainMap`](collections.html#collections.ChainMap "collections.ChainMap")
* [`collections.abc.Awaitable`](collections.abc... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
b84d14f3-a75e-5053-9556-7587c6385860 | docs | python | python_stdtypes | 312 | 196 | * [`collections.abc.Iterator`](collections.abc.html#collections.abc.Iterator "collections.abc.Iterator")
* [`collections.abc.Generator`](collections.abc.html#collections.abc.Generator "collections.abc.Generator")
* [`collections.abc.Reversible`](collections.abc.html#collections.abc.Reversible "collections.abc.Reversibl... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
089e56e3-718b-5157-b9b5-0a056107cb2c | docs | python | python_stdtypes | 312 | 197 | * [`collections.abc.MutableMapping`](collections.abc.html#collections.abc.MutableMapping "collections.abc.MutableMapping")
* [`collections.abc.Sequence`](collections.abc.html#collections.abc.Sequence "collections.abc.Sequence")
* [`collections.abc.MutableSequence`](collections.abc.html#collections.abc.MutableSequence "... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
b92ec12d-0b8a-5516-a419-4277cbf842cf | docs | python | python_stdtypes | 312 | 198 | * [`contextlib.AbstractContextManager`](contextlib.html#contextlib.AbstractContextManager "contextlib.AbstractContextManager")
* [`contextlib.AbstractAsyncContextManager`](contextlib.html#contextlib.AbstractAsyncContextManager "contextlib.AbstractAsyncContextManager")
* [`dataclasses.Field`](dataclasses.html#dataclasse... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
0d702c66-b571-5d35-ac48-cdf4d4f0b4fc | docs | python | python_stdtypes | 312 | 199 | * [`shelve.DbfilenameShelf`](shelve.html#shelve.DbfilenameShelf "shelve.DbfilenameShelf")
* [`shelve.Shelf`](shelve.html#shelve.Shelf "shelve.Shelf")
* [`types.MappingProxyType`](types.html#types.MappingProxyType "types.MappingProxyType")
* [`weakref.WeakKeyDictionary`](weakref.html#weakref.WeakKeyDictionary "weakref.W... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
726c01cf-7f39-5822-b2d6-8eb64dcf505b | docs | python | python_stdtypes | 312 | 200 | genericalias.\_\_args\_\_[¶](#genericalias.__args__ "Link to this definition")
: This attribute is a [`tuple`](#tuple "tuple") (possibly of length 1) of generic
types passed to the original [`__class_getitem__()`](../reference/datamodel.html#object.__class_getitem__ "object.__class_getitem__") of the
generic ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
7711e866-ac4e-55e3-8b54-57e77410faa6 | docs | python | python_stdtypes | 312 | 201 | [`typing.ParamSpec`](typing.html#typing.ParamSpec "typing.ParamSpec") is intended primarily for static type checking.
genericalias.\_\_unpacked\_\_[¶](#genericalias.__unpacked__ "Link to this definition")
: A boolean that is true if the alias has been unpacked using the
`*` operator (see [`TypeVarTuple`](typ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
1e445cd8-8b71-5d6f-a8ab-666d77be1868 | docs | python | python_stdtypes | 312 | 202 | [Generics](typing.html#generics), [user-defined generics](typing.html#user-defined-generics) and [`typing.Generic`](typing.html#typing.Generic "typing.Generic")
: Documentation on how to implement generic classes that can be
parameterized at runtime and understood by static type-checkers.
Added in version 3.9.
... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
2e81e931-2f6c-5d6e-ae1f-eb0783ff2073 | docs | python | python_stdtypes | 312 | 203 | ```None
def square(number: int | float) -> int | float:
return number ** 2
```
Note
The `|` operand cannot be used at runtime to define unions where one or
more members is a forward reference. For example, `int | "Foo"`, where
`"Foo"` is a reference to a class not yet defined, will... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
29b3942b-8e28-52b7-920f-61e997a90777 | docs | python | python_stdtypes | 312 | 204 | * Optional types can be spelled as a union with `None`:
```None
str | None == typing.Optional[str]
```
isinstance(obj, union\_object)
issubclass(obj, union\_object)
: Calls to [`isinstance()`](functions.html#isinstance "isinstance") and [`issubclass()`](functions.html#issubclass "issubclass")... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
6fd24c6c-f94c-5c9d-93af-f4c63cdc3533 | docs | python | python_stdtypes | 312 | 205 | instantiated from the type:
```None
>>> import types
>>> isinstance(int | str, types.UnionType)
True
>>> types.UnionType()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create 'types.UnionType' instances
```
Note
The `__or__()` method for type objects was added to support... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
fb34f68f-b3ae-5e7f-a718-0153a5df54c1 | docs | python | python_stdtypes | 312 | 206 | ### Modules[¶](#modules "Link to this heading")
The only special operation on a module is attribute access: `m.name`, where
*m* is a module and *name* accesses a name defined in *m*’s symbol table.
Module attributes can be assigned to. (Note that the [`import`](../reference/simple_stmts.html#import)
statement is not, ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
8aa55eff-6a12-5e63-b638-e757dcb1bc2b | docs | python | python_stdtypes | 312 | 207 | `m.__dict__ = {}`). Modifying [`__dict__`](../reference/datamodel.html#object.__dict__ "object.__dict__") directly is
not recommended.
Modules built into the interpreter are written like this: `<module 'sys'
(built-in)>`. If loaded from a file, they are written as `<module 'os' from
'/usr/local/lib/pythonX.Y/os.pyc'>`... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
ed858711-c1d8-5b62-a7b6-3e1a344c37a1 | docs | python | python_stdtypes | 312 | 208 | See [Function definitions](../reference/compound_stmts.html#function) for more information.
### Methods[¶](#methods "Link to this heading")
Methods are functions that are called using the attribute notation. There are
two flavors: [built-in methods](../reference/datamodel.html#builtin-methods) (such as `append()`
on ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
fd8af33d-7b14-5625-8ded-054d015be4aa | docs | python | python_stdtypes | 312 | 209 | the function implementing the method. Calling `m(arg-1, arg-2, ..., arg-n)`
is completely equivalent to calling `m.__func__(m.__self__, arg-1, arg-2, ...,
arg-n)`.
Like [function objects](../reference/datamodel.html#user-defined-funcs), bound method objects support
getting arbitrary
attributes. However, since method a... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
d02d84f9-21c5-5056-aa07-e5704e74d72d | docs | python | python_stdtypes | 312 | 210 | AttributeError: 'method' object has no attribute 'whoami'
>>> c.method.__func__.whoami = 'my name is method'
>>> c.method.whoami
'my name is method'
```
See [Instance methods](../reference/datamodel.html#instance-methods) for more information.
### Code Objects[¶](#code-objects "Link to this heading")
Code objects ar... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
0cc73c0a-80d5-5acc-91c5-070fa52aefc9 | docs | python | python_stdtypes | 312 | 211 | Accessing [`__code__`](../reference/datamodel.html#function.__code__ "function.__code__") raises an [auditing event](sys.html#auditing)
`object.__getattr__` with arguments `obj` and `"__code__"`.
A code object can be executed or evaluated by passing it (instead of a source
string) to the [`exec()`](functions.html#exec... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
3f0aeed3-6a98-5cb0-8a29-9168d151eed9 | docs | python | python_stdtypes | 312 | 212 | ### The Null Object[¶](#the-null-object "Link to this heading")
This object is returned by functions that don’t explicitly return a value. It
supports no special operations. There is exactly one null object, named
`None` (a built-in name). `type(None)()` produces the same singleton.
It is written as `None`.
### The ... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
2694070c-9915-5196-80e9-a1c8e23c9ade | docs | python | python_stdtypes | 312 | 213 | asked to operate on types they don’t support. See [Comparisons](../reference/expressions.html#comparisons) for more
information. There is exactly one [`NotImplemented`](constants.html#NotImplemented "NotImplemented") object.
`type(NotImplemented)()` produces the singleton instance.
It is written as `NotImplemented`.
... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
c4c8fa44-dc7a-5f39-b73b-2882ae83ad11 | docs | python | python_stdtypes | 312 | 214 | : The name of the class, function, method, descriptor, or
generator instance.
definition.\_\_qualname\_\_[¶](#definition.__qualname__ "Link to this definition")
: The [qualified name](../glossary.html#term-qualified-name) of the class, function, method, descriptor,
or generator instance.
Added in vers... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
d34d6949-bb9f-5113-bfb2-92eb0c34b2a9 | docs | python | python_stdtypes | 312 | 215 | ## Integer string conversion length limitation[¶](#integer-string-conversion-length-limitation "Link to this heading")
CPython has a global limit for converting between [`int`](functions.html#int "int") and [`str`](#str "str")
to mitigate denial of service attacks. This limit *only* applies to decimal or
other non-pow... | large_dataset/raw/docs/python/stdtypes/stdtypes_312.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.