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
f6380c59-561d-5361-b8ca-ed6f74c62be0
docs
python
python_stdtypes
315
197
set.update(*\*others*)[¶](#set.update "Link to this definition") set |= other | ... : Update the set, adding elements from all others. set.intersection\_update(*\*others*)[¶](#set.intersection_update "Link to this definition") set &= other & ... : Update the set, keeping only elements found in it and all others....
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
1b1ae072-885e-58b2-9443-2543f3777017
docs
python
python_stdtypes
315
198
set.discard(*elem*, */*)[¶](#set.discard "Link to this definition") : Remove element *elem* from the set if it is present. set.pop()[¶](#set.pop "Link to this definition") : Remove and return an arbitrary element from the set. Raises [`KeyError`](exceptions.html#KeyError "KeyError") if the set is empty. set.c...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
c1d3a207-4b31-5262-92c8-d4d842f3b55d
docs
python
python_stdtypes
315
199
[`discard()`](#set.discard "set.discard") methods may be a set. To support searching for an equivalent frozenset, a temporary one is created from *elem*. ## Mapping Types — [`dict`](#dict "dict")[¶](#mapping-types-dict "Link to this heading") A [mapping](../glossary.html#term-mapping) object maps [hashable](../glossa...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
82273cba-52ce-58cf-a768-1459114f9fa1
docs
python
python_stdtypes
315
200
Values that compare equal (such as `1`, `1.0`, and `True`) can be used interchangeably to index the same dictionary entry. *class* dict(*\*\*kwargs*)[¶](#dict "Link to this definition") *class* dict(*mapping*, */*, *\*\*kwargs*) *class* dict(*iterable*, */*, *\*\*kwargs*) : Return a new dictionary initialized from...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
b4e24b95-d372-5365-b253-1c7fdd433bbf
docs
python
python_stdtypes
315
201
dictionary is created by calling [`__getitem__()`](../reference/datamodel.html#object.__getitem__ "object.__getitem__") on the argument with each returned key from the method. Otherwise, the positional argument must be an [iterable](../glossary.html#term-iterable) object. Each item in the iterable must itse...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
d1df6ebb-a210-51b1-b89a-89f2c2f07862
docs
python
python_stdtypes
315
202
value)` pairs (regardless of ordering). Order comparisons (‘<’, ‘<=’, ‘>=’, ‘>’) raise [`TypeError`](exceptions.html#TypeError "TypeError"). To illustrate dictionary creation and equality, the following examples all return a dictionary equal to `{"one": 1, "two": 2, "three": 3}`: ```None >>> a ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
935e45cc-aba8-5759-8d12-c7ae049b5835
docs
python
python_stdtypes
315
203
>>> d = {"one": 1, "two": 2, "three": 3, "four": 4} >>> d {'one': 1, 'two': 2, 'three': 3, 'four': 4} >>> list(d) ['one', 'two', 'three', 'four'] >>> list(d.values()) [1, 2, 3, 4] >>> d["one"] = 42 >>> d {'one': 42, 'two': 2, 'three': 3, 'four': 4} >>> del d["two"] >>> d[...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
e7f41212-62f3-57fb-bf93-b5ba2220b2f6
docs
python
python_stdtypes
315
204
If a subclass of dict defines a method [`__missing__()`](../reference/datamodel.html#object.__missing__ "object.__missing__") and *key* is not present, the `d[key]` operation calls that method with the key *key* as argument. The `d[key]` operation then returns or raises whatever is retur...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
6801c2f6-d171-5074-a3b5-6dff9a54335b
docs
python
python_stdtypes
315
205
>>> c['red'] += 1 >>> c['red'] 1 ``` The example above shows part of the implementation of [`collections.Counter`](collections.html#collections.Counter "collections.Counter"). A different `__missing__()` method is used by [`collections.defaultdict`](colle...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
f8fae205-2ae7-5237-a7a3-5453b695120f
docs
python
python_stdtypes
315
206
: Return a shallow copy of the dictionary. *classmethod* fromkeys(*iterable*, *value=None*, */*)[¶](#dict.fromkeys "Link to this definition") : Create a new dictionary with keys from *iterable* and values set to *value*. [`fromkeys()`](#dict.fromkeys "dict.fromkeys") is a class method that ret...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
e5bb556a-0cf7-5929-8276-45a44fceba86
docs
python
python_stdtypes
315
207
: Return a new view of the dictionary’s items (`(key, value)` pairs). See the [documentation of view objects](#dict-views). keys()[¶](#dict.keys "Link to this definition") : Return a new view of the dictionary’s keys. See the [documentation of view objects](#dict-views). pop(*key*,...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
2d63a8b3-7547-5883-bfd1-54570f55af80
docs
python
python_stdtypes
315
208
[`popitem()`](#dict.popitem "dict.popitem") raises a [`KeyError`](exceptions.html#KeyError "KeyError"). Changed in version 3.7: LIFO order is now guaranteed. In prior versions, [`popitem()`](#dict.popitem "dict.popitem") would return an arbitrary key/value pair. reversed(d) : Return ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
8cb32778-b2e2-51d5-971d-ea8ebfe0835b
docs
python
python_stdtypes
315
209
[`update()`](#dict.update "dict.update") accepts either another object with a `keys()` method (in which case [`__getitem__()`](../reference/datamodel.html#object.__getitem__ "object.__getitem__") is called with every key returned from the method) or an iterable of key/value pairs (as tuples or o...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
b47e0a64-a6d9-59e6-bf4d-ac2f44a0baef
docs
python
python_stdtypes
315
210
: Create a new dictionary with the merged keys and values of *d* and *other*, which must both be dictionaries. The values of *other* take priority when *d* and *other* share keys. Added in version 3.9. d |= other : Update the dictionary *d* with keys and values from *other*, wh...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
d6f720f2-4f45-5378-b947-b2b202c54f02
docs
python
python_stdtypes
315
211
See also [`types.MappingProxyType`](types.html#types.MappingProxyType "types.MappingProxyType") can be used to create a read-only view of a [`dict`](#dict "dict"). ### Dictionary view objects[¶](#dictionary-view-objects "Link to this heading") The objects returned by [`dict.keys()`](#dict.keys "dict.keys"), [`dict.v...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
7ce56959-1325-5acf-b7e6-10aaf94e63d2
docs
python
python_stdtypes
315
212
using [`zip()`](functions.html#zip "zip"): `pairs = zip(d.values(), d.keys())`. Another way to create the same list is `pairs = [(v, k) for (k, v) in d.items()]`. Iterating views while adding or deleting entries in the dictionary may raise a [`RuntimeError`](exceptions.html#RuntimeError "RuntimeError")...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
d1c28774-842a-59a5-b0bd-94de8bdc9117
docs
python
python_stdtypes
315
213
Added in version 3.10. Keys views are set-like since their entries are unique and [hashable](../glossary.html#term-hashable). Items views also have set-like operations since the (key, value) pairs are unique and the keys are hashable. If all values in an items view are hashable as well, then the items view can int...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
26b1f4fc-316a-5995-baa1-82a648e0be5f
docs
python
python_stdtypes
315
214
>>> print(n) 504 >>> # keys and values are iterated over in the same order (insertion order) >>> list(keys) ['eggs', 'sausage', 'bacon', 'spam'] >>> list(values) [2, 1, 1, 500] >>> # view objects are dynamic and reflect dict changes >>> del dishes['eggs'] >>> del dishes['sausage'] >>> list(keys) ['bacon', 'spam'] >>...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
e07784e9-ed65-5878-b4e6-a479018adb58
docs
python
python_stdtypes
315
215
that allow user-defined classes to define a runtime context that is entered before the statement body is executed and exited when the statement ends: contextmanager.\_\_enter\_\_()[¶](#contextmanager.__enter__ "Link to this definition") : Enter the runtime context and return either this object or another object ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
d671a54e-242e-5dcb-a6b1-7cf6a167e925
docs
python
python_stdtypes
315
216
returned by [`decimal.localcontext()`](decimal.html#decimal.localcontext "decimal.localcontext"). These managers set the active decimal context to a copy of the original decimal context and then return the copy. This allows changes to be made to the current decimal context in the body of the [`with`](.....
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
91143c51-542e-52f3-b467-baa2aec1ca42
docs
python
python_stdtypes
315
217
Returning a true value from this method will cause the [`with`](../reference/compound_stmts.html#with) statement to suppress the exception and continue execution with the statement immediately following the `with` statement. Otherwise the exception continues propagating after this method has finished ex...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
e7e1193d-e5b2-51ac-9cf2-ac20de831164
docs
python
python_stdtypes
315
218
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_315.md
90c8f7b9-020b-52e4-8670-81b8fe6af9e7
docs
python
python_stdtypes
315
219
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_315.md
c70a95fd-65d6-52ad-85ef-0dd9ad59110b
docs
python
python_stdtypes
315
220
### 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_315.md
8fbd1d80-7f66-5ebb-87ca-06cb404bb412
docs
python
python_stdtypes
315
221
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_315.md
b3b70507-6f30-559f-ac5d-e8824831ea2d
docs
python
python_stdtypes
315
222
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_315.md
0290d402-b8e6-58aa-b0ec-1dec53a0c205
docs
python
python_stdtypes
315
223
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_315.md
7984a128-2692-516b-bfbf-1d7588d97ed9
docs
python
python_stdtypes
315
224
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_315.md
20b01a57-f8a6-57a2-8750-9082d81cff12
docs
python
python_stdtypes
315
225
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_315.md
13e44218-e507-55ee-8847-a97e73e9d7d8
docs
python
python_stdtypes
315
226
* [`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_315.md
d9a23e2d-6390-57ab-a91e-54a9c5af9799
docs
python
python_stdtypes
315
227
* [`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_315.md
fa9c6805-33f3-5cfb-afdb-d39452232092
docs
python
python_stdtypes
315
228
* [`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_315.md
6283da08-2bbd-5daf-8cd8-2e1a0c479513
docs
python
python_stdtypes
315
229
* [`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_315.md
388d6af6-5f0c-513c-bdb5-567896969f0a
docs
python
python_stdtypes
315
230
* [`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_315.md
0e962f9b-ec4f-532b-86bb-2545ab5453b7
docs
python
python_stdtypes
315
231
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_315.md
82818127-b3dc-52a1-8c91-30f979503f38
docs
python
python_stdtypes
315
232
[`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_315.md
a1be2f99-6ace-5b13-be65-d5bce4a17d7d
docs
python
python_stdtypes
315
233
[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_315.md
03615154-6ad0-5731-90be-9190faa2f414
docs
python
python_stdtypes
315
234
[`int`](functions.html#int "int") or [`float`](functions.html#float "float"): ```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 exampl...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
62f9c530-8c16-5577-8c4e-69f74a83bbb0
docs
python
python_stdtypes
315
235
* It creates instances of [`typing.Union`](typing.html#typing.Union "typing.Union"): ```None int | str == typing.Union[int, str] type(int | str) is typing.Union ``` * Optional types can be spelled as a union with `None`: ```None str | None == typing.Optional[str] ``` ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
40300c4a-4772-5df1-ba6f-51076fe82a14
docs
python
python_stdtypes
315
236
The user-exposed type for the union object can be accessed from [`typing.Union`](typing.html#typing.Union "typing.Union") and used for [`isinstance()`](functions.html#isinstance "isinstance") checks: ```None >>> import typing >>> isinstance(int | str, typing.Union) True >>> typing.Union() Traceback (most recent call l...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
f2ae800b-a4da-549c-a6ef-71c61b270772
docs
python
python_stdtypes
315
237
Changed in version 3.14: Union objects are now instances of [`typing.Union`](typing.html#typing.Union "typing.Union"). Previously, they were instances of [`types.UnionType`](types.html#types.UnionType "types.UnionType"), which remains an alias for [`typing.Union`](typing.html#typing.Union "typing.Union"). ## Other Bui...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
10e81f59-832f-57bd-84aa-337d32175924
docs
python
python_stdtypes
315
238
A special attribute of every module is [`__dict__`](../reference/datamodel.html#object.__dict__ "object.__dict__"). This is the dictionary containing the module’s symbol table. Modifying this dictionary will actually change the module’s symbol table, but direct assignment to the [`__dict__`](../reference/datamodel.html...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
e2636e77-4a58-5ec2-b616-9091ae708feb
docs
python
python_stdtypes
315
239
See [Objects, values and types](../reference/datamodel.html#objects) and [Class definitions](../reference/compound_stmts.html#class) for these. ### Functions[¶](#functions "Link to this heading") Function objects are created by function definitions. The only operation on a function object is to call it: `func(argumen...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
5fe57559-dcb8-5389-be20-0f5c5274f689
docs
python
python_stdtypes
315
240
Built-in methods are described with the types that support them. If you access a method (a function defined in a class namespace) through an instance, you get a special object: a *bound method* (also called [instance method](../reference/datamodel.html#instance-methods)) object. When called, it will add the `self` arg...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
ecb86a03-8478-5ab8-8d74-a9fcfd72a9aa
docs
python
python_stdtypes
315
241
underlying function object ([`method.__func__`](../reference/datamodel.html#method.__func__ "method.__func__")), setting method attributes on bound methods is disallowed. Attempting to set an attribute on a method results in an [`AttributeError`](exceptions.html#AttributeError "AttributeError") being raised. In order t...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
b8e8a266-cce3-5688-8a78-484b0cb53f76
docs
python
python_stdtypes
315
242
### Code Objects[¶](#code-objects "Link to this heading") Code objects are used by the implementation to represent “pseudo-compiled” executable Python code such as a function body. They differ from function objects because they don’t contain a reference to their global execution environment. Code objects are returned ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
96164380-f33b-555f-9661-521183874ff1
docs
python
python_stdtypes
315
243
string) to the [`exec()`](functions.html#exec "exec") or [`eval()`](functions.html#eval "eval") built-in functions. See [The standard type hierarchy](../reference/datamodel.html#types) for more information. ### Type Objects[¶](#type-objects "Link to this heading") Type objects represent the various object types. An ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
e0d57db5-259c-5726-aca3-69626683c012
docs
python
python_stdtypes
315
244
### The Ellipsis Object[¶](#the-ellipsis-object "Link to this heading") This object is commonly used to indicate that something is omitted. It supports no special operations. There is exactly one ellipsis object, named [`Ellipsis`](constants.html#Ellipsis "Ellipsis") (a built-in name). `type(Ellipsis)()` produces the ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
1757f865-f63f-5e4e-b118-71675cfd89b0
docs
python
python_stdtypes
315
245
* Doctest’s [`ELLIPSIS`](doctest.html#doctest.ELLIPSIS "doctest.ELLIPSIS"), as a pattern for missing content. * The default Python prompt of the [interactive](../glossary.html#term-interactive) shell when partial input is incomplete. Lastly, the Python documentation often uses three dots in conventional English usage ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
7f14708e-da03-5c40-b069-b95a1b8c5396
docs
python
python_stdtypes
315
246
### Internal Objects[¶](#internal-objects "Link to this heading") See [The standard type hierarchy](../reference/datamodel.html#types) for this information. It describes [stack frame objects](../reference/datamodel.html#frame-objects), [traceback objects](../reference/datamodel.html#traceback-objects), and slice objec...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
da7bcdb6-ea90-559c-a981-5713b90e9ce6
docs
python
python_stdtypes
315
247
definition.\_\_module\_\_[¶](#definition.__module__ "Link to this definition") : The name of the module in which a class or function was defined. definition.\_\_doc\_\_[¶](#definition.__doc__ "Link to this definition") : The documentation string of a class or function, or `None` if undefined. definition.\_\_type\...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
ffa88994-e432-5a36-b4df-417ca3beb8d9
docs
python
python_stdtypes
315
248
other non-power-of-two number bases. Hexadecimal, octal, and binary conversions are unlimited. The limit can be configured. The [`int`](functions.html#int "int") type in CPython is an arbitrary length number stored in binary form (commonly known as a “bignum”). There exists no algorithm that can convert a string to a ...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
61c3a6e7-e736-5482-99f3-a519c5c50dc4
docs
python
python_stdtypes
315
249
When an operation would exceed the limit, a [`ValueError`](exceptions.html#ValueError "ValueError") is raised: ```None >>> import sys >>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default. >>> _ = int('2' * 5432) Traceback (most recent call last): ... ValueError: Exceeds the limit (4300 digits) for...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
12ba286c-f49c-5a78-9c29-bcef87afb397
docs
python
python_stdtypes
315
250
[`sys.int_info.str_digits_check_threshold`](sys.html#sys.int_info "sys.int_info"). Verification: ```None >>> import sys >>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info >>> assert sys.int_info.str_digits_check_threshold == 640, sys.int_info >>> msg = int('578966293710682886880994035146873798396722...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
46ad9107-6e76-517a-88e3-319a65748f75
docs
python
python_stdtypes
315
251
The limitations do not apply to functions with a linear algorithm: * `int(string, base)` with base 2, 4, 8, 16, or 32. * [`int.from_bytes()`](#int.from_bytes "int.from_bytes") and [`int.to_bytes()`](#int.to_bytes "int.to_bytes"). * [`hex()`](functions.html#hex "hex"), [`oct()`](functions.html#oct "oct"), [`bin()`](fun...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
8e2d34df-798f-5689-9042-4cb0f824afb2
docs
python
python_stdtypes
315
252
* [`-X int_max_str_digits`](../using/cmdline.html#cmdoption-X), e.g. `python3 -X int_max_str_digits=640` * [`sys.flags.int_max_str_digits`](sys.html#sys.flags.int_max_str_digits "sys.flags.int_max_str_digits") contains the value of [`PYTHONINTMAXSTRDIGITS`](../using/cmdline.html#envvar-PYTHONINTMAXSTRDIGITS) or [`-...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
1fb6b183-4213-5aa6-934d-3b7059c5f0a0
docs
python
python_stdtypes
315
253
* [`sys.get_int_max_str_digits()`](sys.html#sys.get_int_max_str_digits "sys.get_int_max_str_digits") and [`sys.set_int_max_str_digits()`](sys.html#sys.set_int_max_str_digits "sys.set_int_max_str_digits") are a getter and setter for the interpreter-wide limit. Subinterpreters have their own limit. Information about...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
21bded04-68b3-5414-9a23-51336a4f8460
docs
python
python_stdtypes
315
254
encounter an error during parsing, usually at startup time or import time or even at installation time - anytime an up to date `.pyc` does not already exist for the code. A workaround for source that contains such large constants is to convert them to `0x` hexadecimal form as it has no limit. Test your application tho...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
d14f88da-1cb5-58da-a513-af4e7f482c0b
docs
python
python_stdtypes
315
255
these APIs were added in security patch releases in versions before 3.12. Example: ```None >>> import sys >>> if hasattr(sys, "set_int_max_str_digits"): ... upper_bound = 68000 ... lower_bound = 4004 ... current_limit = sys.get_int_max_str_digits() ... if current_limit == 0 or current_limit > upper_bo...
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
692e7410-16f5-55e0-8cec-c5df58fd3b25
docs
python
python_stdtypes
315
256
Cased characters are those with general category property being one of “Lu” (Letter, uppercase), “Ll” (Letter, lowercase), or “Lt” (Letter, titlecase). [5] ([1](#id10),[2](#id11)) To format only a tuple you should therefore provide a singleton tuple whose only element is the tuple to be formatted.
large_dataset/raw/docs/python/stdtypes/stdtypes_315.md
fdaa3c2c-7bf1-5d80-9017-739788e9d1da
docs
python
python_stdtypes
38
0
# Built-in Types¶ Source: https://docs.python.org/3.8/library/stdtypes.html Version: 3.8 The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some collection classes are mutable. The...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
23bbf133-bffc-51b9-82f5-3d29affc5dbc
docs
python
python_stdtypes
38
1
## Truth Value Testing[¶](#truth-value-testing "Permalink to this headline") Any object can be tested for truth value, for use in an [`if`](../reference/compound_stmts.html#if) or [`while`](../reference/compound_stmts.html#while) condition or as operand of the Boolean operations below. By default, an object is consid...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
2bd5fdca-108d-56d1-ae3a-f166045b94b1
docs
python
python_stdtypes
38
2
or `False` for false and `1` or `True` for true, unless otherwise stated. (Important exception: the Boolean operations `or` and `and` always return one of their operands.) ## Boolean Operations — `and`, `or`, `not`[¶](#boolean-operations-and-or-not "Permalink to this headline") These are the Boolean operations, order...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
e0392eb2-78fc-5196-a28c-016466c13004
docs
python
python_stdtypes
38
3
## Comparisons[¶](#comparisons "Permalink to this headline") There are eight comparison operations in Python. They all have the same priority (which is higher than that of the Boolean operations). Comparisons can be chained arbitrarily; for example, `x < y <= z` is equivalent to `x < y and y <= z`, except that *y* is ...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
ecc18651-7c02-5a40-be30-0e7382fb14a4
docs
python
python_stdtypes
38
4
operators are only defined where they make sense; for example, they raise a [`TypeError`](exceptions.html#TypeError "TypeError") exception when one of the arguments is a complex number. Non-identical instances of a class normally compare as non-equal unless the class defines the [`__eq__()`](../reference/datamodel.htm...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
acdcadb7-7e03-5604-ac10-5fabb45dbd07
docs
python
python_stdtypes
38
5
conventional meanings of the comparison operators). The behavior of the [`is`](../reference/expressions.html#is) and [`is not`](../reference/expressions.html#is-not) operators cannot be customized; also they can be applied to any two objects and never raise an exception. Two more operations with the same syntactic pr...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
0f3815f0-82de-568c-bac4-12df0f00a24c
docs
python
python_stdtypes
38
6
numbers are usually implemented using `double` in C; information about the precision and internal representation of floating point numbers for the machine on which your program is running is available in [`sys.float_info`](sys.html#sys.float_info "sys.float_info"). Complex numbers have a real and imaginary part, which ...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
04409c5a-24a4-5457-a2c3-4ca5f40cb9f4
docs
python
python_stdtypes
38
7
numeric literal yields an imaginary number (a complex number with a zero real part) which you can add to an integer or float to get a complex number with real and imaginary parts. Python fully supports mixed arithmetic: when a binary arithmetic operator has operands of different numeric types, the operand with the “na...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
ae8d421a-a5a9-550e-91b5-38b7b27bc328
docs
python
python_stdtypes
38
8
| --- | --- | --- | --- | | `x + y` | sum of *x* and *y* | | | | `x - y` | difference of *x* and *y* | | | | `x * y` | product of *x* and *y* | | | | `x / y` | quotient of *x* and *y* | | | | `x // y` | floored quotient of *x* and *y* | (1) | | | `x % y` | remainder of `x / y` | (2) | | | `-x` | *x* negated |...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
1087733c-69ab-5bd9-85fd-ac668db4053a
docs
python
python_stdtypes
38
9
| `pow(x, y)` | *x* to the power *y* | (5) | [`pow()`](functions.html#pow "pow") | | `x ** y` | *x* to the power *y* | (5) | | Notes: 1. Also referred to as integer division. The resultant value is a whole integer, though the result’s type is not necessarily int. The result is always rounded towards minus infi...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
805295c2-66b1-56e2-bffd-8e95042336b0
docs
python
python_stdtypes
38
10
6. The numeric literals accepted include the digits `0` to `9` or any Unicode equivalent (code points with the `Nd` property). See <http://www.unicode.org/Public/12.1.0/ucd/extracted/DerivedNumericType.txt> for a complete list of code points with the `Nd` property. All [`numbers.Real`](numbers.html#numbers.R...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
b02fff06-40a9-5459-a6d8-2b72ec9eb809
docs
python
python_stdtypes
38
11
| [`math.ceil(x)`](math.html#math.ceil "math.ceil") | the least [`Integral`](numbers.html#numbers.Integral "numbers.Integral") >= *x* | For additional numeric operations see the [`math`](math.html#module-math "math: Mathematical functions (sin() etc.).") and [`cmath`](cmath.html#module-cmath "cmath: Mathematical funct...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
fe12d8f7-4054-5735-92ea-a3e1a7d6b484
docs
python
python_stdtypes
38
12
| `x | y` | bitwise *or* of *x* and *y* | (4) | | `x ^ y` | bitwise *exclusive or* of *x* and *y* | (4) | | `x & y` | bitwise *and* of *x* and *y* | (4) | | `x << n` | *x* shifted left by *n* bits | (1)(2) | | `x >> n` | *x* shifted right by *n* bits | (1)(3) | | `~x` | the bits of *x* inverted | | Notes: 1. Negativ...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
0fcb9eab-fb39-5ec4-9e29-103c6763793b
docs
python
python_stdtypes
38
13
### Additional Methods on Integer Types[¶](#additional-methods-on-integer-types "Permalink to this headline") The int type implements the [`numbers.Integral`](numbers.html#numbers.Integral "numbers.Integral") [abstract base class](../glossary.html#term-abstract-base-class). In addition, it provides a few more methods:...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
91cd54ec-28b8-5d49-9616-a2817cf0a4da
docs
python
python_stdtypes
38
14
s = bin(self) # binary representation: bin(-37) --> '-0b100101' s = s.lstrip('-0b') # remove leading zeros and minus sign return len(s) # len('100101') --> 6 ``` New in version 3.1. `int.``to_bytes`(*length*, *byteorder*, *\**, *signed=False*)[¶](#int.to_bytes "Permalink t...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
d3365dff-7a54-5ff0-86ad-edb434a2d232
docs
python
python_stdtypes
38
15
The *byteorder* argument determines the byte order used to represent the integer. If *byteorder* is `"big"`, the most significant byte is at the beginning of the byte array. If *byteorder* is `"little"`, the most significant byte is at the end of the byte array. To request the native byte order of t...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
8af35d3f-123c-5fcc-802e-19ff764de1fe
docs
python
python_stdtypes
38
16
>>> int.from_bytes(b'\x00\x10', byteorder='little') 4096 >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=True) -1024 >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=False) 64512 >>> int.from_bytes([255, 0, 0], byteorder='big') 16711680 ``` The argument *bytes* mu...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
063b6ae0-52f5-567d-ab9d-b848f5300a6d
docs
python
python_stdtypes
38
17
`int.``as_integer_ratio`()[¶](#int.as_integer_ratio "Permalink to this definition") : Return a pair of integers whose ratio is exactly equal to the original integer and with a positive denominator. The integer ratio of integers (whole numbers) is always the integer as the numerator and `1` as the denomina...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
70c3a7c7-9d3b-5707-bbc6-d95075464299
docs
python
python_stdtypes
38
18
`float.``is_integer`()[¶](#float.is_integer "Permalink to this definition") : Return `True` if the float instance is finite with integral value, and `False` otherwise: ```None >>> (-2.0).is_integer() True >>> (3.2).is_integer() False ``` Two methods support conversion to and from hexadec...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
c7b87dbb-c54a-5ab0-955d-22d912bc0873
docs
python
python_stdtypes
38
19
: Class method to return the float represented by a hexadecimal string *s*. The string *s* may have leading and trailing whitespace. Note that [`float.hex()`](#float.hex "float.hex") is an instance method, while [`float.fromhex()`](#float.fromhex "float.fromhex") is a class method. A hexadecimal string take...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
0998be13-8b22-5ff5-8f7d-585ffa07008f
docs
python
python_stdtypes
38
20
character or Java’s `Double.toHexString` are accepted by [`float.fromhex()`](#float.fromhex "float.fromhex"). Note that the exponent is written in decimal rather than hexadecimal, and that it gives the power of 2 by which to multiply the coefficient. For example, the hexadecimal string `0x3.a7p10` represents the float...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
1cd78080-1469-5f8f-ab34-1594849587c7
docs
python
python_stdtypes
38
21
efficiency across a variety of numeric types (including [`int`](functions.html#int "int"), [`float`](functions.html#float "float"), [`decimal.Decimal`](decimal.html#decimal.Decimal "decimal.Decimal") and [`fractions.Fraction`](fractions.html#fractions.Fraction "fractions.Fraction")) Python’s hash for numeric types is b...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
d0b55785-2132-560a-ba8c-95817e8b9959
docs
python
python_stdtypes
38
22
longs and `P = 2**61 - 1` on machines with 64-bit C longs. Here are the rules in detail: * If `x = m / n` is a nonnegative rational number and `n` is not divisible by `P`, define `hash(x)` as `m * invmod(n, P) % P`, where `invmod(n, P)` gives the inverse of `n` modulo `P`. * If `x = m / n` is a nonnegative ration...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
116cdf42-95fb-5750-b22d-7f13d75f933e
docs
python
python_stdtypes
38
23
and imaginary parts are combined by computing `hash(z.real) + sys.hash_info.imag * hash(z.imag)`, reduced modulo `2**sys.hash_info.width` so that it lies in `range(-2**(sys.hash_info.width - 1), 2**(sys.hash_info.width - 1))`. Again, if the result is `-1`, it’s replaced with `-2`. To clarify the above rules,...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
9e125827-e52a-5202-8a7b-36fb88581047
docs
python
python_stdtypes
38
24
# Fermat's Little Theorem: pow(n, P-1, P) is 1, so # pow(n, P-2, P) gives the inverse of n modulo P. hash_value = (abs(m) % P) * pow(n, P - 2, P) % P if m < 0: hash_value = -hash_value if hash_value == -1: hash_value = -2 return hash_value def hash_float(x): """C...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
437a690b-9dac-5e68-a04c-f16eb7a333c6
docs
python
python_stdtypes
38
25
## Iterator Types[¶](#iterator-types "Permalink to this headline") Python supports a concept of iteration over containers. This is implemented using two distinct methods; these are used to allow user-defined classes to support iteration. Sequences, described below in more detail, always support the iteration methods. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
76e8519a-a040-53c0-b02d-3a212115d41d
docs
python
python_stdtypes
38
26
[`tp_iter`](../c-api/typeobj.html#c.PyTypeObject.tp_iter "PyTypeObject.tp_iter") slot of the type structure for Python objects in the Python/C API. The iterator objects themselves are required to support the following two methods, which together form the *iterator protocol*: `iterator.``__iter__`()[¶](#iterat...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
a3cc409b-3f53-59a8-97d4-a06dfba610ed
docs
python
python_stdtypes
38
27
the [`StopIteration`](exceptions.html#StopIteration "StopIteration") exception. This method corresponds to the [`tp_iternext`](../c-api/typeobj.html#c.PyTypeObject.tp_iternext "PyTypeObject.tp_iternext") slot of the type structure for Python objects in the Python/C API. Python defines several iterator obje...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
f3464689-482d-51d1-a2c6-4154a6d357f1
docs
python
python_stdtypes
38
28
protocol. If a container object’s [`__iter__()`](../reference/datamodel.html#object.__iter__ "object.__iter__") method is implemented as a generator, it will automatically return an iterator object (technically, a generator object) supplying the [`__iter__()`](../reference/datamodel.html#object.__iter__ "object.__iter_...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
9645ad0c-5280-5d55-94e5-e5bcd72ada1a
docs
python
python_stdtypes
38
29
### Common Sequence Operations[¶](#common-sequence-operations "Permalink to this headline") The operations in the following table are supported by most sequence types, both mutable and immutable. The [`collections.abc.Sequence`](collections.abc.html#collections.abc.Sequence "collections.abc.Sequence") ABC is provided ...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
d36ceea5-6d83-561b-869a-7fb625e21b2b
docs
python
python_stdtypes
38
30
| `x not in s` | `False` if an item of *s* is equal to *x*, else `True` | (1) | | `s + t` | the concatenation of *s* and *t* | (6)(7) | | `s * n` or `n * s` | equivalent to adding *s* to itself *n* times | (2)(7) | | `s[i]` | *i*th item of *s*, origin 0 | (3) | | `s[i:j]` | slice of *s* from *i* to *j* | (3)(4) | | `s[...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
79807166-b441-5208-bd55-776c43d0df1c
docs
python
python_stdtypes
38
31
details see [Comparisons](../reference/expressions.html#comparisons) in the language reference.) Notes: 1. While the `in` and `not in` operations are used only for simple containment testing in the general case, some specialised sequences (such as [`str`](#str "str"), [`bytes`](#bytes "bytes") and [`bytearray`]...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
e42ea93c-36eb-5ca8-a8db-dbdbbd586265
docs
python
python_stdtypes
38
32
list. Modifying any of the elements of `lists` modifies this single list. You can create a list of different lists this way: ```None >>> lists = [[] for i in range(3)] >>> lists[0].append(3) >>> lists[1].append(5) >>> lists[2].append(7) >>> lists [[3], [5], [7]] ``` Further explanatio...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
5392ae26-1b6f-505f-804a-cb1ded6c49c3
docs
python
python_stdtypes
38
33
items with index `x = i + n*k` such that `0 <= n < (j-i)/k`. In other words, the indices are `i`, `i+k`, `i+2*k`, `i+3*k` and so on, stopping when *j* is reached (but never including *j*). When *k* is positive, *i* and *j* are reduced to `len(s)` if they are greater. When *k* is negative, *i* and *j* are...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
9d5def64-e139-5d1b-9991-ddd97d0a529b
docs
python
python_stdtypes
38
34
[`str.join()`](#str.join "str.join") at the end or else write to an [`io.StringIO`](io.html#io.StringIO "io.StringIO") instance and retrieve its value when complete * if concatenating [`bytes`](#bytes "bytes") objects, you can similarly use [`bytes.join()`](#bytes.join "bytes.join") or [`io.BytesIO`](...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
0fdb5034-f140-5d7a-8d92-12a8e29b86a0
docs
python
python_stdtypes
38
35
Not all implementations support passing the additional arguments *i* and *j*. These arguments allow efficient searching of subsections of the sequence. Passing the extra arguments is roughly equivalent to using `s[i:j].index(x)`, only without copying any data and with the returned index being relative to ...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
b9ff797d-9ba3-5553-9394-a4a016eb8f7e
docs
python
python_stdtypes
38
36
### Mutable Sequence Types[¶](#mutable-sequence-types "Permalink to this headline") The operations in the following table are defined on mutable sequence types. The [`collections.abc.MutableSequence`](collections.abc.html#collections.abc.MutableSequence "collections.abc.MutableSequence") ABC is provided to make it eas...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
e3cf1110-caeb-5798-84db-cf0ceffcc8ee
docs
python
python_stdtypes
38
37
| `del s[i:j:k]` | removes the elements of `s[i:j:k]` from the list | | | `s.append(x)` | appends *x* to the end of the sequence (same as `s[len(s):len(s)] = [x]`) | | | `s.clear()` | removes all items from *s* (same as `del s[:]`) | (5) | | `s.copy()` | creates a shallow copy of *s* (same as `s[:]`) | (5) | | `s.ext...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
c93ebd4d-8dbd-542e-a608-9de56205ea0a
docs
python
python_stdtypes
38
38
3. `remove()` raises [`ValueError`](exceptions.html#ValueError "ValueError") when *x* is not found in *s*. 4. The `reverse()` method modifies the sequence in place for economy of space when reversing a large sequence. To remind users that it operates by side effect, it does not return the reversed sequence. 5. `c...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md
5d943c33-6536-5eb6-9f99-7b158afec145
docs
python
python_stdtypes
38
39
the sequence. Items in the sequence are not copied; they are referenced multiple times, as explained for `s * n` under [Common Sequence Operations](#typesseq-common). ### Lists[¶](#lists "Permalink to this headline") Lists are mutable sequences, typically used to store collections of homogeneous items (where th...
large_dataset/raw/docs/python/stdtypes/stdtypes_38.md