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
1a2c5b47-6fb7-5911-8bc1-cc1ad8c94bda
docs
python
python_datamodel
314
148
* **mappings**, where *subscript* is also called the [key](../glossary.html#term-key). See [mapping documentation](#datamodel-mappings) for the expected behavior. If *subscript* is of an inappropriate type, `__getitem__()` should raise [`TypeError`](../library/exceptions.html#TypeError "TypeErr...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
78b308f7-e675-5e60-a7ae-9c41e98e674c
docs
python
python_datamodel
314
149
When [subscripting](expressions.html#subscriptions) a *class*, the special class method [`__class_getitem__()`](#object.__class_getitem__ "object.__class_getitem__") may be called instead of `__getitem__()`. See [\_\_class\_getitem\_\_ versus \_\_getitem\_\_](#classgetitem-versus-getitem) for more detai...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
cc6ecaba-b316-557d-829a-e47e1e661b63
docs
python
python_datamodel
314
150
: Called to implement deletion of `self[key]`. Same note as for [`__getitem__()`](#object.__getitem__ "object.__getitem__"). This should only be implemented for mappings if the objects support removal of keys, or for sequences if elements can be removed from the sequence. The same exceptions should be rai...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
bd96dd60-eeb0-5238-a8a6-8f60887a6edc
docs
python
python_datamodel
314
151
objects in the container. For mappings, it should iterate over the keys of the container. object.\_\_reversed\_\_(*self*)[¶](#object.__reversed__ "Link to this definition") : Called (if present) by the [`reversed()`](../library/functions.html#reversed "reversed") built-in to implement reverse iteration. ...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
8b7c18d9-ae72-5e4b-902c-2838c3fb2912
docs
python
python_datamodel
314
152
that is more efficient than the one provided by [`reversed()`](../library/functions.html#reversed "reversed"). The membership test operators ([`in`](expressions.html#in) and [`not in`](expressions.html#not-in)) are normally implemented as an iteration through a container. However, container objects can supply the ...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
0ee63a57-6b36-5d73-afde-27e0fb5fa0ad
docs
python
python_datamodel
314
153
protocol via [`__getitem__()`](#object.__getitem__ "object.__getitem__"), see [this section in the language reference](expressions.html#membership-test-details). ### 3.3.8. Emulating numeric types[¶](#emulating-numeric-types "Link to this heading") The following methods can be defined to emulate numeric objec...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
58e8a032-123b-5859-afc1-dc6f7456751a
docs
python
python_datamodel
314
154
object.\_\_floordiv\_\_(*self*, *other*)[¶](#object.__floordiv__ "Link to this definition") object.\_\_mod\_\_(*self*, *other*)[¶](#object.__mod__ "Link to this definition") object.\_\_divmod\_\_(*self*, *other*)[¶](#object.__divmod__ "Link to this definition") object.\_\_pow\_\_(*self*, *other*[, *modulo*])[¶](#obj...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
9fd393fb-0844-5192-a625-7d1b77bd3e77
docs
python
python_datamodel
314
155
[`pow()`](../library/functions.html#pow "pow"), `**`, `<<`, `>>`, `&`, `^`, `|`). For instance, to evaluate the expression `x + y`, where *x* is an instance of a class that has an [`__add__()`](#object.__add__ "object.__add__") method, `type(x).__add__(x, y)` is called. The [`__divmod__()`](#object.__di...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
8c0ac4df-84cf-535c-aa2d-7c0211054717
docs
python
python_datamodel
314
156
arguments, it should return [`NotImplemented`](../library/constants.html#NotImplemented "NotImplemented"). object.\_\_radd\_\_(*self*, *other*)[¶](#object.__radd__ "Link to this definition") object.\_\_rsub\_\_(*self*, *other*)[¶](#object.__rsub__ "Link to this definition") object.\_\_rmul\_\_(*self*, *other*)[¶...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
c8311721-9ca2-5f2a-9c59-c623359cec9c
docs
python
python_datamodel
314
157
object.\_\_rrshift\_\_(*self*, *other*)[¶](#object.__rrshift__ "Link to this definition") object.\_\_rand\_\_(*self*, *other*)[¶](#object.__rand__ "Link to this definition") object.\_\_rxor\_\_(*self*, *other*)[¶](#object.__rxor__ "Link to this definition") object.\_\_ror\_\_(*self*, *other*)[¶](#object.__ror__ "Lin...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
34b70eb3-5dc1-5151-80b2-f3af1036ea96
docs
python
python_datamodel
314
158
an instance of a class that has an [`__rsub__()`](#object.__rsub__ "object.__rsub__") method, `type(y).__rsub__(y, x)` is called if `type(x).__sub__(x, y)` returns [`NotImplemented`](../library/constants.html#NotImplemented "NotImplemented") or `type(y)` is a subclass of `type(x)`. [[5]](#id24) Note th...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
bccf32fa-76ce-5297-90b3-afa959eda70e
docs
python
python_datamodel
314
159
for the operation, this method will be called before the left operand’s non-reflected method. This behavior allows subclasses to override their ancestors’ operations. object.\_\_iadd\_\_(*self*, *other*)[¶](#object.__iadd__ "Link to this definition") object.\_\_isub\_\_(*self*, *other*)[¶](#object.__isub_...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
4da7bc5e-ec86-5088-8194-427760a4c0ed
docs
python
python_datamodel
314
160
object.\_\_irshift\_\_(*self*, *other*)[¶](#object.__irshift__ "Link to this definition") object.\_\_iand\_\_(*self*, *other*)[¶](#object.__iand__ "Link to this definition") object.\_\_ixor\_\_(*self*, *other*)[¶](#object.__ixor__ "Link to this definition") object.\_\_ior\_\_(*self*, *other*)[¶](#object.__ior__ "Lin...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
00dd65af-2888-552a-b797-baae74ebc2b8
docs
python
python_datamodel
314
161
equivalent to `x = x.__iadd__(y)` . If [`__iadd__()`](#object.__iadd__ "object.__iadd__") does not exist, or if `x.__iadd__(y)` returns `NotImplemented`, `x.__add__(y)` and `y.__radd__(x)` are considered, as with the evaluation of `x + y`. In certain situations, augmented assignment can result in unexpe...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
0569b305-b5bc-5a53-bbb1-8e7db08e7e1a
docs
python
python_datamodel
314
162
object.\_\_complex\_\_(*self*)[¶](#object.__complex__ "Link to this definition") object.\_\_int\_\_(*self*)[¶](#object.__int__ "Link to this definition") object.\_\_float\_\_(*self*)[¶](#object.__float__ "Link to this definition") : Called to implement the built-in functions [`complex()`](../library/functions.html#...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
b6f67075-a5bd-531d-add4-319bdd4d154a
docs
python
python_datamodel
314
163
functions). Presence of this method indicates that the numeric object is an integer type. Must return an integer. If [`__int__()`](#object.__int__ "object.__int__"), [`__float__()`](#object.__float__ "object.__float__") and [`__complex__()`](#object.__complex__ "object.__complex__") are not defined the...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
2d55b98e-1d0b-5781-a7c7-d953a2e67601
docs
python
python_datamodel
314
164
: Called to implement the built-in function [`round()`](../library/functions.html#round "round") and [`math`](../library/math.html#module-math "math: Mathematical functions (sin() etc.).") functions [`trunc()`](../library/math.html#math.trunc "math.trunc"), [`floor()`](../library/math.html#math.floor "math.floor"...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
d3f31e6e-cf29-55b1-83d9-0f6c8a34b74a
docs
python
python_datamodel
314
165
### 3.3.9. With Statement Context Managers[¶](#with-statement-context-managers "Link to this heading") A *context manager* is an object that defines the runtime context to be established when executing a [`with`](compound_stmts.html#with) statement. The context manager handles the entry into, and the exit from, the de...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
a62a0f36-88b1-5d67-b1da-50841e73a466
docs
python
python_datamodel
314
166
object.\_\_enter\_\_(*self*)[¶](#object.__enter__ "Link to this definition") : Enter the runtime context related to this object. The [`with`](compound_stmts.html#with) statement will bind this method’s return value to the target(s) specified in the `as` clause of the statement, if any. object.\_\_exit\_\_(*s...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
0009f55a-beb3-580b-b243-5a9fadf5f9ee
docs
python
python_datamodel
314
167
Note that [`__exit__()`](#object.__exit__ "object.__exit__") methods should not reraise the passed-in exception; this is the caller’s responsibility. See also [**PEP 343**](https://peps.python.org/pep-0343/) - The “with” statement : The specification, background, and examples for the Python [`with`](compoun...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
e16a0867-e7c7-56cd-a127-274be4224b43
docs
python
python_datamodel
314
168
used in a class pattern with positional arguments, each positional argument will be converted into a keyword argument, using the corresponding value in *\_\_match\_args\_\_* as the keyword. The absence of this attribute is equivalent to setting it to `()`. For example, if `MyClass.__match_args__` is `(...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
c3fab370-3f43-5dd4-a860-e62d908964a8
docs
python
python_datamodel
314
169
### 3.3.11. Emulating buffer types[¶](#emulating-buffer-types "Link to this heading") The [buffer protocol](../c-api/buffer.html#bufferobjects) provides a way for Python objects to expose efficient access to a low-level memory array. This protocol is implemented by builtin types such as [`bytes`](../library/stdtypes.h...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
c970c32c-b75b-5918-8f32-05737285b6e9
docs
python
python_datamodel
314
170
the returned buffer is read-only or writable. [`inspect.BufferFlags`](../library/inspect.html#inspect.BufferFlags "inspect.BufferFlags") provides a convenient way to interpret the flags. The method must return a [`memoryview`](../library/stdtypes.html#memoryview "memoryview") object. object.\_\_release\_bu...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
0b43da4e-de17-5471-b6a3-1fb49d923d34
docs
python
python_datamodel
314
171
: Introduces the Python `__buffer__` and `__release_buffer__` methods. [`collections.abc.Buffer`](../library/collections.abc.html#collections.abc.Buffer "collections.abc.Buffer") : ABC for buffer types. ### 3.3.12. Annotations[¶](#annotations "Link to this heading") Functions, classes, and modules may contain [a...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
4590b429-abd6-59d0-b501-1beb5451136b
docs
python
python_datamodel
314
172
object.\_\_annotate\_\_(*format*)[¶](#object.__annotate__ "Link to this definition") : An [annotate function](../glossary.html#term-annotate-function). Returns a new dictionary object mapping attribute/parameter names to their annotation values. Takes a format parameter specifying the format in which annotat...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
ee4597c6-cf47-5c59-b987-c64cceb70312
docs
python
python_datamodel
314
173
[`NotImplementedError()`](../library/exceptions.html#NotImplementedError "NotImplementedError") when called with this format. When called with [`VALUE`](../library/annotationlib.html#annotationlib.Format.VALUE "annotationlib.Format.VALUE") format, an annotate function may raise [`NameError`](../library/exc...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
d526966f-80de-52fd-a96e-c6ddcd93ee6a
docs
python
python_datamodel
314
174
### 3.3.13. Special method lookup[¶](#special-method-lookup "Link to this heading") For custom classes, implicit invocations of special methods are only guaranteed to work correctly if defined on an object’s type, not in the object’s instance dictionary. That behaviour is the reason why the following code raises an ex...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
c72b8509-3e3f-589c-81ed-e20fce6ee0c0
docs
python
python_datamodel
314
175
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: descriptor '__hash__' of 'int' object needs an argument ``` Incorrectly attempting to invoke an unbound method of a class in this way is sometimes referred to as ‘metaclass confusion’, and is avoided by bypassing the instance when look...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
609573df-3744-5ce7-a6eb-42d7256ff34b
docs
python
python_datamodel
314
176
... print("Class getattribute invoked") ... return object.__getattribute__(*args) ... >>> c = C() >>> c.__len__() # Explicit lookup via instance Class getattribute invoked 10 >>> type(c).__len__(c) # Explicit lookup via type Metaclass getattribute invoked 10 >>> len(c) ...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
74eb51f1-c69e-58d3-b771-794da7e30c09
docs
python
python_datamodel
314
177
[Coroutine objects](../glossary.html#term-coroutine) returned from [`async def`](compound_stmts.html#async-def) functions are awaitable. Note The [generator iterator](../glossary.html#term-generator-iterator) objects returned from generators decorated with [`types.coroutine()`](../library/types.html#types.coroutine "...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
439c278f-3c16-5cdc-bdc3-4dadc86776fb
docs
python
python_datamodel
314
178
The language doesn’t place any restriction on the type or value of the objects yielded by the iterator returned by `__await__`, as this is specific to the implementation of the asynchronous execution framework (e.g. [`asyncio`](../library/asyncio.html#module-asyncio "asyncio: Asynchronous I/O.")) that w...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
ee62a6ff-9582-51f0-ac57-63c19871264a
docs
python
python_datamodel
314
179
returns, the iterator raises [`StopIteration`](../library/exceptions.html#StopIteration "StopIteration"), and the exception’s [`value`](../library/exceptions.html#StopIteration.value "StopIteration.value") attribute holds the return value. If the coroutine raises an exception, it is propagated by the iterator. Coroutin...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
55bccccf-497e-53ab-a2b5-94239a81c870
docs
python
python_datamodel
314
180
this is equivalent to advancing the iterator returned by [`__await__()`](#object.__await__ "object.__await__"). If *value* is not `None`, this method delegates to the [`send()`](expressions.html#generator.send "generator.send") method of the iterator that caused the coroutine to suspend. The result (ret...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
6b7b179d-3b66-5a09-a7df-26dd0e3d16da
docs
python
python_datamodel
314
181
(return value, [`StopIteration`](../library/exceptions.html#StopIteration "StopIteration"), or other exception) is the same as when iterating over the [`__await__()`](#object.__await__ "object.__await__") return value, described above. If the exception is not caught in the coroutine, it propagates back ...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
7d1b70a6-3c1f-58f5-bd37-81beb4ff2d22
docs
python
python_datamodel
314
182
Finally, the coroutine is marked as having finished executing, even if it was never started. Coroutine objects are automatically closed using the above process when they are about to be destroyed. ### 3.4.3. Asynchronous Iterators[¶](#asynchronous-iterators "Link to this heading") An *asynchronous it...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
a51573d0-39c7-53a7-8567-a51278998e95
docs
python
python_datamodel
314
183
An example of an asynchronous iterable object: ```None class Reader: async def readline(self): ... def __aiter__(self): return self async def __anext__(self): val = await self.readline() if val == b'': raise StopAsyncIteration return val ``` Added in v...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
d75478a9-2095-5724-ba08-51a8ab016b73
docs
python
python_datamodel
314
184
suspend execution in its `__aenter__` and `__aexit__` methods. Asynchronous context managers can be used in an [`async with`](compound_stmts.html#async-with) statement. The [`object`](../library/functions.html#object "object") class itself does not provide these methods. object.\_\_aenter\_\_(*self*)[¶](#object.__ae...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
7355b8a0-e008-5c9c-bf7e-b72b40be9840
docs
python
python_datamodel
314
185
Added in version 3.5. Footnotes [[1](#id1)] It *is* possible in some cases to change an object’s type, under certain controlled conditions. It generally isn’t a good idea though, since it can lead to some very strange behaviour if it is handled incorrectly. [[2](#id12)] The [`__hash__()`](#object.__hash__ "object...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
2fe98308-a018-5b71-a154-c55828aab324
docs
python
python_datamodel
314
186
the method returns [`NotImplemented`](../library/constants.html#NotImplemented "NotImplemented"). Do not set the method to `None` if you want to force fallback to the right operand’s reflected method—that will instead have the opposite effect of explicitly *blocking* such fallback. [[4](#id17)] For operands of the s...
large_dataset/raw/docs/python/datamodel/datamodel_314.md
2c5fa6dd-5f89-5320-841a-f5fd95857a35
docs
python
python_datamodel
315
0
# 3.Data model¶ Source: https://docs.python.org/3.15/reference/datamodel.html Version: 3.15 ## 3.1. Objects, values and types[¶](#objects-values-and-types "Link to this heading") *Objects* are Python’s abstraction for data. All data in a Python program is represented by objects or by relations between objects. Even ...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
70393607-30c8-501b-b7f1-92e549695e54
docs
python
python_datamodel
315
1
type. The [`type()`](../library/functions.html#type "type") function returns an object’s type (which is an object itself). Like its identity, an object’s *type* is also unchangeable. [[1]](#id20) The *value* of some objects can change. Objects whose value can change are said to be *mutable*; objects whose value is unc...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
fd15bd24-487e-5f20-b3ce-7727be41c4e2
docs
python
python_datamodel
315
2
they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether — it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that are still reachable. **CPython implementation detail:** CPython currently uses a re...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
c7127e03-0693-55cf-b09c-8b54b3a84808
docs
python
python_datamodel
315
3
keep objects alive that would normally be collectable. Also note that catching an exception with a [`try`](compound_stmts.html#try)…[`except`](compound_stmts.html#except) statement may keep objects alive. Some objects contain references to “external” resources such as open files or windows. It is understood that these...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
3b4a6ba4-b483-5628-8d5e-44ab487dc44b
docs
python
python_datamodel
315
4
container, we imply the values, not the identities of the contained objects; however, when we talk about the mutability of a container, only the identities of the immediately contained objects are implied. So, if an immutable container (like a tuple) contains a reference to a mutable object, its value changes if that m...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
90a6198c-b8db-5b23-8eb4-ae4092dc2ff1
docs
python
python_datamodel
315
5
not be relied upon, but is something to be aware of when making use of object identity tests. However, after `c = []; d = []`, *c* and *d* are guaranteed to refer to two different, unique, newly created empty lists. (Note that `e = f = []` assigns the *same* object to both *e* and *f*.) ## 3.2. The standard type hiera...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
5719a118-5945-5250-af2d-9f3b7d4c944f
docs
python
python_datamodel
315
6
### 3.2.1. None[¶](#none "Link to this heading") This type has a single value. There is a single object with this value. This object is accessed through the built-in name `None`. It is used to signify the absence of a value in many situations, e.g., it is returned from functions that don’t explicitly return anything. ...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
9cc7aa6e-b44e-5107-9f63-bb06524f844d
docs
python
python_datamodel
315
7
for more details. Changed in version 3.9: Evaluating [`NotImplemented`](../library/constants.html#NotImplemented "NotImplemented") in a boolean context was deprecated. Changed in version 3.14: Evaluating [`NotImplemented`](../library/constants.html#NotImplemented "NotImplemented") in a boolean context now raises a [`...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
52122a1a-23a1-5305-bcd6-a9bf092964a7
docs
python
python_datamodel
315
8
### 3.2.4. [`numbers.Number`](../library/numbers.html#numbers.Number "numbers.Number")[¶](#numbers-number "Link to this heading") These are created by numeric literals and returned as results by arithmetic operators and arithmetic built-in functions. Numeric objects are immutable; once created their value never change...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
6d5c21c9-cc24-5fe9-9f71-4c609b01e067
docs
python
python_datamodel
315
9
decimal point, are not shown. * A sign is shown only when the number is negative. Python distinguishes between integers, floating-point numbers, and complex numbers: #### 3.2.4.1. [`numbers.Integral`](../library/numbers.html#numbers.Integral "numbers.Integral")[¶](#numbers-integral "Link to this heading") These re...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
7a427b78-14f4-5d4c-99a0-f04745605af9
docs
python
python_datamodel
315
10
Booleans ([`bool`](../library/functions.html#bool "bool")) : These represent the truth values False and True. The two objects representing the values `False` and `True` are the only Boolean objects. The Boolean type is a subtype of the integer type, and Boolean values behave like the values 0 and 1, respe...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
2971f605-52c4-5048-9023-df99a9eef3cc
docs
python
python_datamodel
315
11
memory usage that are usually the reason for using these are dwarfed by the overhead of using objects in Python, so there is no reason to complicate the language with two kinds of floating-point numbers. #### 3.2.4.3. [`numbers.Complex`](../library/numbers.html#numbers.Complex "numbers.Complex") ([`complex`](../librar...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
16af484f-7548-547d-80d3-6e179d8728a6
docs
python
python_datamodel
315
12
…, *n*-1. Item *i* of sequence *a* is selected by `a[i]`. Some sequences, including built-in sequences, interpret negative subscripts by adding the sequence length. For example, `a[-2]` equals `a[n-2]`, the second to last item of sequence a with length `n`. The resulting value must be a nonnegative integer less than t...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
3b401eae-9bcc-521f-8b4c-ed2e6b2d706f
docs
python
python_datamodel
315
13
the length of the sequence. Some sequences also support “extended slicing” with a third “step” parameter: `a[i:j:k]` selects all items of *a* with index *x* where `x = i + n*k`, *n* `>=` `0` and *i* `<=` *x* `<` *j*. Sequences are distinguished according to their mutability: #### 3.2.5.1. Immutable sequences[¶](#imm...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
31f825be-b60e-50f3-931d-15bff55e5923
docs
python
python_datamodel
315
14
Instead, every code point in the string is represented as a string object with length `1`. The built-in function [`ord()`](../library/functions.html#ord "ord") converts a code point from its string form to an integer in the range `0` to `0x10FFFF`; [`chr()`](../library/functions.html#chr "chr") con...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
cca57cda-80e4-5246-b3bc-eb274a87ebc2
docs
python
python_datamodel
315
15
of one item (a ‘singleton’) can be formed by affixing a comma to an expression (an expression by itself does not create a tuple, since parentheses must be usable for grouping of expressions). An empty tuple can be formed by an empty pair of parentheses. Bytes : A [`bytes`](../library/stdtypes.html#by...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
31472a3f-370c-5efd-93fb-e48fea76f908
docs
python
python_datamodel
315
16
The [`collections`](../library/collections.html#module-collections "collections: Container datatypes") and [`array`](../library/array.html#module-array "array: Space efficient arrays of uniformly typed numeric values.") module provide additional examples of mutable sequence types. There are currently two intrinsic mut...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
80cdde36-5f72-50a1-8f75-4a5e8cead53e
docs
python
python_datamodel
315
17
### 3.2.6. Set types[¶](#set-types "Link to this heading") These represent unordered, finite sets of unique, immutable objects. As such, they cannot be indexed by any subscript. However, they can be iterated over, and the built-in function [`len()`](../library/functions.html#len "len") returns the number of items in a...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
6c87e705-c3ce-52c5-9067-bb8b28158fa0
docs
python
python_datamodel
315
18
[`add()`](../library/stdtypes.html#set.add "set.add"). Frozen sets : These represent an immutable set. They are created by the built-in [`frozenset()`](../library/stdtypes.html#frozenset "frozenset") constructor. As a frozenset is immutable and [hashable](../glossary.html#term-hashable), it can be used a...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
cfc67b53-e26e-53a8-bd65-f51aa9bca581
docs
python
python_datamodel
315
19
#### 3.2.7.1. Dictionaries[¶](#dictionaries "Link to this heading") These represent finite sets of objects indexed by nearly arbitrary values. The only types of values not acceptable as keys are values containing lists or dictionaries or other mutable types that are compared by value rather than by object identity, th...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
04e82121-5fde-5d6f-8e3c-45fb66515f6b
docs
python
python_datamodel
315
20
section [Dictionary displays](expressions.html#dict)). The extension modules [`dbm.ndbm`](../library/dbm.html#module-dbm.ndbm "dbm.ndbm: The New Database Manager (Unix)") and [`dbm.gnu`](../library/dbm.html#module-dbm.gnu "dbm.gnu: GNU database manager (Unix)") provide additional examples of mapping types, as does the...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
af92d808-c0bd-5b1b-94d6-18b27061faae
docs
python
python_datamodel
315
21
#### 3.2.8.1. User-defined functions[¶](#user-defined-functions "Link to this heading") A user-defined function object is created by a function definition (see section [Function definitions](compound_stmts.html#function)). It should be called with an argument list containing the same number of items as the function’s ...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
5698c2d8-ebae-5378-abde-5fdef9c71832
docs
python
python_datamodel
315
22
| function.\_\_closure\_\_[¶](#function.__closure__ "Link to this definition") | `None` or a [`tuple`](../library/stdtypes.html#tuple "tuple") of cells that contain bindings for the names specified in the [`co_freevars`](#codeobject.co_freevars "codeobject.co_freevars") attribute of the function’s [`code object`](#func...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
6a843e6e-a287-510d-b437-532fe41977f9
docs
python
python_datamodel
315
23
| function.\_\_qualname\_\_[¶](#function.__qualname__ "Link to this definition") | The function’s [qualified name](../glossary.html#term-qualified-name). See also: [`__qualname__ attributes`](../library/stdtypes.html#definition.__qualname__ "definition.__qualname__"). Added in version 3.3. | | function.\_\_module\_\_[...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
efaf81ea-ae85-54c9-b7aa-bec2be32b26a
docs
python
python_datamodel
315
24
| function.\_\_dict\_\_[¶](#function.__dict__ "Link to this definition") | The namespace supporting arbitrary function attributes. See also: [`__dict__ attributes`](#object.__dict__ "object.__dict__"). | | function.\_\_annotations\_\_[¶](#function.__annotations__ "Link to this definition") | A [`dictionary`](../library...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
1b45d125-75bf-571c-b9ae-a443cedce6a0
docs
python
python_datamodel
315
25
| function.\_\_annotate\_\_[¶](#function.__annotate__ "Link to this definition") | The [annotate function](../glossary.html#term-annotate-function) for this function, or `None` if the function has no annotations. See [`object.__annotate__`](#object.__annotate__ "object.__annotate__"). Added in version 3.14. | | functi...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
c7fa2e3b-e543-5277-8080-c20a32fdf5d7
docs
python
python_datamodel
315
26
dot-notation is used to get and set such attributes. **CPython implementation detail:** CPython’s current implementation only supports function attributes on user-defined functions. Function attributes on [built-in functions](#builtin-functions) may be supported in the future. Additional information about a function’...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
1c6f05f0-fae5-52af-a897-01f8205dbc90
docs
python
python_datamodel
315
27
| method.\_\_doc\_\_[¶](#method.__doc__ "Link to this definition") | The method’s documentation (same as [`method.__func__.__doc__`](#function.__doc__ "function.__doc__")). A [`string`](../library/stdtypes.html#str "str") if the original function had a docstring, else `None`. | | method.\_\_name\_\_[¶](#method.__name__...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
6c845432-54f2-5c03-aaad-cab3c74fdfef
docs
python
python_datamodel
315
28
[`classmethod`](../library/functions.html#classmethod "classmethod") object. When an instance method object is created by retrieving a user-defined [function object](#user-defined-funcs) from a class via one of its instances, its [`__self__`](#method.__self__ "method.__self__") attribute is the instance, and the metho...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
9175fd04-1286-5dd7-ad39-939015e4e99a
docs
python
python_datamodel
315
29
([`__self__`](#method.__self__ "method.__self__")) in front of the argument list. For instance, when `C` is a class which contains a definition for a function `f()`, and `x` is an instance of `C`, calling `x.f(1)` is equivalent to calling `C.f(x, 1)`. When an instance method object is derived from a [`classmethod`](.....
large_dataset/raw/docs/python/datamodel/datamodel_315.md
28e1d110-3364-5dce-8ef2-452ac3022838
docs
python
python_datamodel
315
30
#### 3.2.8.3. Generator functions[¶](#generator-functions "Link to this heading") A function or method which uses the [`yield`](simple_stmts.html#yield) statement (see section [The yield statement](simple_stmts.html#yield)) is called a *generator function*. Such a function, when called, always returns an [iterator](.....
large_dataset/raw/docs/python/datamodel/datamodel_315.md
8a54e359-6ab8-519d-beb4-217b7127d036
docs
python
python_datamodel
315
31
#### 3.2.8.4. Coroutine functions[¶](#coroutine-functions "Link to this heading") A function or method which is defined using [`async def`](compound_stmts.html#async-def) is called a *coroutine function*. Such a function, when called, returns a [coroutine](../glossary.html#term-coroutine) object. It may contain [`awai...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
df6b7761-4999-5358-abc5-e262f7172ff7
docs
python
python_datamodel
315
32
[`async for`](compound_stmts.html#async-for) statement to execute the body of the function. Calling the asynchronous iterator’s [`aiterator.__anext__`](#object.__anext__ "object.__anext__") method will return an [awaitable](../glossary.html#term-awaitable) which when awaited will execute until it provides a value usin...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
32ceb8b8-fd97-5456-936c-5bcdc1abee19
docs
python
python_datamodel
315
33
built-in functions are [`len()`](../library/functions.html#len "len") and [`math.sin()`](../library/math.html#math.sin "math.sin") ([`math`](../library/math.html#module-math "math: Mathematical functions (sin() etc.).") is a standard built-in module). The number and type of the arguments are determined by the C functio...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
ea6ef4a1-2596-5e0e-9a84-4fe73e51108d
docs
python
python_datamodel
315
34
#### 3.2.8.7. Built-in methods[¶](#built-in-methods "Link to this heading") This is really a different disguise of a built-in function, this time containing an object passed to the C function as an implicit extra argument. An example of a built-in method is `alist.append()`, assuming *alist* is a list object. In this ...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
29499bc8-fec7-5127-b4b8-bb28ecffb4b6
docs
python
python_datamodel
315
35
#### 3.2.8.9. Class Instances[¶](#class-instances "Link to this heading") Instances of arbitrary classes can be made callable by defining a [`__call__()`](#object.__call__ "object.__call__") method in their class. ### 3.2.9. Modules[¶](#modules "Link to this heading") Modules are a basic organizational unit of Pytho...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
baddece7-008e-5d53-ad26-7a7852684c89
docs
python
python_datamodel
315
36
translated to lookups in this dictionary, e.g., `m.x` is equivalent to `m.__dict__["x"]`. A module object does not contain the code object used to initialize the module (since it isn’t needed once the initialization is done). Attribute assignment updates the module’s namespace dictionary, e.g., `m.x = 1` is equivalent...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
656db60b-117e-50e2-9d1b-2c5ff5d306d8
docs
python
python_datamodel
315
37
it’s recommended to use [`importlib.util.module_from_spec()`](../library/importlib.html#importlib.util.module_from_spec "importlib.util.module_from_spec"), which will set the various import-controlled attributes to appropriate values. It’s also possible to use the [`types.ModuleType`](../library/types.html#types.Module...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
7d963676-9b75-5beb-a197-9e0aad845e34
docs
python
python_datamodel
315
38
>>> typing.__spec__.name = 'spelling' >>> typing.__name__, typing.__spec__.name ('typing', 'spelling') >>> typing.__name__ = 'keyboard_smashing' >>> typing.__name__, typing.__spec__.name ('keyboard_smashing', 'spelling') ``` module.\_\_name\_\_[¶](#module.__name__ "Link to this definition") : The name used to unique...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
14b38308-5bb3-5a8e-8d09-c3fa2c880a2c
docs
python
python_datamodel
315
39
used when importing the module. See [Module specs](import.html#module-specs) for more details. Added in version 3.4. module.\_\_package\_\_[¶](#module.__package__ "Link to this definition") : The [package](../glossary.html#term-package) a module belongs to. If the module is top-level (that is, not a pa...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
83b84a0b-26d9-58c4-987f-7943e29461f9
docs
python
python_datamodel
315
40
use [`importlib.util.module_from_spec()`](../library/importlib.html#importlib.util.module_from_spec "importlib.util.module_from_spec") instead to ensure the attribute is set to a [`str`](../library/stdtypes.html#str "str"). It is **strongly** recommended that you use [`module.__spec__.parent`](../libra...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
e021e8c8-3568-57f6-952a-a91c05f77f04
docs
python
python_datamodel
315
41
[`__spec__.parent`](../library/importlib.html#importlib.machinery.ModuleSpec.parent "importlib.machinery.ModuleSpec.parent"). [`__package__`](#module.__package__ "module.__package__") is now only used as a fallback during import resolution if `__spec__.parent` is not defined. Changed in version 3.10: [...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
8878567f-9989-55e5-b001-d98cf3a643b9
docs
python
python_datamodel
315
42
by the import system or standard library. module.\_\_loader\_\_[¶](#module.__loader__ "Link to this definition") : The [loader](../glossary.html#term-loader) object that the import machinery used to load the module. This attribute is mostly useful for introspection, but can be used for additional loader...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
94b052a7-9a93-5735-90ae-99ac15dbb76b
docs
python
python_datamodel
315
43
instead of `module.__loader__`. Changed in version 3.4: This attribute now defaults to `None` for modules created dynamically using the [`types.ModuleType`](../library/types.html#types.ModuleType "types.ModuleType") constructor. Previously the attribute was optional. Deprecated since version 3.12,...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
b15d65a0-7188-5d00-a9ae-4c0cc5288fcd
docs
python
python_datamodel
315
44
[`module.__spec__.submodule_search_locations`](../library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations "importlib.machinery.ModuleSpec.submodule_search_locations") instead of `module.__path__`. module.\_\_file\_\_[¶](#module.__file__ "Link to this definition") : `__file__` is an o...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
6b973890-6054-54dd-8de1-39471c72cd5e
docs
python
python_datamodel
315
45
Deprecated since version 3.13, removed in version 3.15: Setting `__cached__` on a module while failing to set `__spec__.cached` is deprecated. In Python 3.15, `__cached__` will cease to be set or taken into consideration by the import system or standard library. Changed in version 3.15: `__cached__...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
094f5562-1c77-5c0e-b140-75ea3f8c5984
docs
python
python_datamodel
315
46
collected during module body execution. For best practices on working with `__annotations__`, see [`annotationlib`](../library/annotationlib.html#module-annotationlib "annotationlib: Functionality for introspecting annotations"). Changed in version 3.14: Annotations are now [lazily evaluated](executionmode...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
c06b8651-2095-57de-836c-abe575f55445
docs
python
python_datamodel
315
47
listed here, `__dict__` cannot be accessed as a global variable from within a module; it can only be accessed as an attribute on module objects. **CPython implementation detail:** Because of the way CPython clears module dictionaries, the module dictionary will be cleared when the module falls out of s...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
53d67c2a-2a42-58e1-bb4e-a9be944d86fa
docs
python
python_datamodel
315
48
name is not found there, the attribute search continues in the base classes. This search of the base classes uses the C3 method resolution order which behaves correctly even in the presence of ‘diamond’ inheritance structures where there are multiple inheritance paths leading back to a common ancestor. Additional detai...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
97fd4397-29c2-531f-9c9a-4669c3c9b630
docs
python
python_datamodel
315
49
[`__dict__`](#object.__dict__ "object.__dict__"). Class attribute assignments update the class’s dictionary, never the dictionary of a base class. A class object can be called (see above) to yield a class instance (see below). #### 3.2.10.1. Special attributes[¶](#special-attributes "Link to this heading") | Attrib...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
d821ad3b-8f63-5fe8-8ad1-d37c39b93f97
docs
python
python_datamodel
315
50
| type.\_\_dict\_\_[¶](#type.__dict__ "Link to this definition") | A [`mapping proxy`](../library/types.html#types.MappingProxyType "types.MappingProxyType") providing a read-only view of the class’s namespace. See also: [`__dict__ attributes`](#object.__dict__ "object.__dict__"). | | type.\_\_bases\_\_[¶](#type.__base...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
fa14af0e-e927-5160-9307-5cade5365637
docs
python
python_datamodel
315
51
| type.\_\_doc\_\_[¶](#type.__doc__ "Link to this definition") | The class’s documentation string, or `None` if undefined. Not inherited by subclasses. | | type.\_\_annotations\_\_[¶](#type.__annotations__ "Link to this definition") | A dictionary containing [variable annotations](../glossary.html#term-variable-annotat...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
221f6550-ae06-51d1-919c-cf8378de8876
docs
python
python_datamodel
315
52
| type.\_\_annotate\_\_()[¶](#type.__annotate__ "Link to this definition") | The [annotate function](../glossary.html#term-annotate-function) for this class, or `None` if the class has no annotations. See also: [`__annotate__ attributes`](#object.__annotate__ "object.__annotate__"). Added in version 3.14. | | type.\_\...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
6d86dde2-a196-58c4-9c67-234dfbe4178b
docs
python
python_datamodel
315
53
| type.\_\_firstlineno\_\_[¶](#type.__firstlineno__ "Link to this definition") | The line number of the first line of the class definition, including decorators. Setting the [`__module__`](#type.__module__ "type.__module__") attribute removes the `__firstlineno__` item from the type’s dictionary. Added in version 3.13...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
d6c75af7-e4be-5625-af4a-6c66a1dbed76
docs
python
python_datamodel
315
54
type.\_\_subclasses\_\_()[¶](#type.__subclasses__ "Link to this definition") : Each class keeps a list of weak references to its immediate subclasses. This method returns a list of all those references still alive. The list is in definition order. Example: ```None >>> class A: pass >>> class B(A)...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
211d8af6-e18b-5d04-8769-388fc836a9d2
docs
python
python_datamodel
315
55
class method objects are also transformed; see above under “Classes”. See section [Implementing Descriptors](#descriptors) for another way in which attributes of a class retrieved via its instances may differ from the objects actually stored in the class’s [`__dict__`](#object.__dict__ "object.__dict__"). If no class a...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
ab511a25-05d2-52a9-900e-056f034c622f
docs
python
python_datamodel
315
56
#### 3.2.11.1. Special attributes[¶](#id5 "Link to this heading") object.\_\_class\_\_[¶](#object.__class__ "Link to this definition") : The class to which a class instance belongs. object.\_\_dict\_\_[¶](#object.__dict__ "Link to this definition") : A dictionary or other mapping object used to store an object’s ...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
1fc8c5cd-cc0c-5f7a-90b5-df7504484721
docs
python
python_datamodel
315
57
[`makefile()`](../library/socket.html#socket.socket.makefile "socket.socket.makefile") method of socket objects (and perhaps by other functions or methods provided by extension modules). The objects `sys.stdin`, `sys.stdout` and `sys.stderr` are initialized to file objects corresponding to the interpreter’s standard i...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
fff38de3-97d7-5df0-a2bb-7656630101b8
docs
python
python_datamodel
315
58
The difference between a code object and a function object is that the function object contains an explicit reference to the function’s globals (the module in which it was defined), while a code object contains no context; also the default argument values are stored in the function object, not in the code object (becau...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
397dc809-09ab-5174-98ab-f4332c857807
docs
python
python_datamodel
315
59
| codeobject.co\_argcount[¶](#codeobject.co_argcount "Link to this definition") | The total number of positional [parameters](../glossary.html#term-parameter) (including positional-only parameters and parameters with default values) that the function has | | codeobject.co\_posonlyargcount[¶](#codeobject.co_posonlyargco...
large_dataset/raw/docs/python/datamodel/datamodel_315.md
d8c264a9-5c81-506d-b9a1-32a616944c2a
docs
python
python_datamodel
315
60
| codeobject.co\_varnames[¶](#codeobject.co_varnames "Link to this definition") | A [`tuple`](../library/stdtypes.html#tuple "tuple") containing the names of the local variables in the function (starting with the parameter names) | | codeobject.co\_cellvars[¶](#codeobject.co_cellvars "Link to this definition") | A [`tu...
large_dataset/raw/docs/python/datamodel/datamodel_315.md