chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
975b7365-ae1c-4ded-9b43-e6f46e692831 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,089 | supabase-export-v2 | e0ec74554020ca25 | class DeepChainMap(ChainMap): 'Variant of ChainMap that allows direct updates to inner scopes'
def __setitem__(self, key, value):
for mapping in self.maps:
if key in mapping:
mapping[key] = value
return
self.maps[0][key] = value | trusted_official_docs | CPython Docs | class DeepChainMap(ChainMap): 'Variant of ChainMap that allows direct updates to inner scopes'
def __setitem__(self, key, value):
for mapping in self.maps:
if key in mapping:
mapping[key] = value
return
self.maps[0][key] = value | class DeepChainMap(ChainMap): 'Variant of ChainMap that allows direct updates to inner scopes'
def __setitem__(self, key, value):
for mapping in self.maps:
if key in mapping:
mapping[key] = value
return
self.maps[0][key] = value | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
97fca5bc-0ec3-4f7c-81ad-f92f78d5aabe | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,190 | supabase-export-v2 | 213d7f546808e744 | deque is not empty, rotating one step to the right is equivalent to ``d.appendleft(d.pop())``, and rotating one step to the left is equivalent to ``d.append(d.popleft())``.
Deque objects also provide one read-only attribute: | trusted_official_docs | CPython Docs | deque is not empty, rotating one step to the right is equivalent to ``d.appendleft(d.pop())``, and rotating one step to the left is equivalent to ``d.append(d.popleft())``.
Deque objects also provide one read-only attribute: | deque is not empty, rotating one step to the right is equivalent to ``d.appendleft(d.pop())``, and rotating one step to the left is equivalent to ``d.append(d.popleft())``.
Deque objects also provide one read-only attribute: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9a0fda1f-b991-4582-b987-4c34c91c169a | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,359 | supabase-export-v2 | ba5f53f93ecd919c | :class:`UserDict` objects -------------------------
The class, :class:`UserDict` acts as a wrapper around dictionary objects. The need for this class has been partially supplanted by the ability to
subclass directly from :class:`dict`; however, this class can be easier
to work with because the underlying dictionary is ... | trusted_official_docs | CPython Docs | :class:`UserDict` objects -------------------------
The class, :class:`UserDict` acts as a wrapper around dictionary objects. The need for this class has been partially supplanted by the ability to
subclass directly from :class:`dict`; however, this class can be easier
to work with because the underlying dictionary is ... | :class:`UserDict` objects -------------------------
The class, :class:`UserDict` acts as a wrapper around dictionary objects. The need for this class has been partially supplanted by the ability to
subclass directly from :class:`dict`; however, this class can be easier
to work with because the underlying dictionary is ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9a238032-d296-412e-a0ab-d1712a1b879d | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,382 | supabase-export-v2 | 0b6b99e2fc3f788b | set to a copy of *seq*. The *seq* argument can be any object which can be converted into a string using the built-in :func:`str` function.
In addition to supporting the methods and operations of strings,
:class:`UserString` instances provide the following attribute: | trusted_official_docs | CPython Docs | set to a copy of *seq*. The *seq* argument can be any object which can be converted into a string using the built-in :func:`str` function.
In addition to supporting the methods and operations of strings,
:class:`UserString` instances provide the following attribute: | set to a copy of *seq*. The *seq* argument can be any object which can be converted into a string using the built-in :func:`str` function.
In addition to supporting the methods and operations of strings,
:class:`UserString` instances provide the following attribute: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9b460654-da2b-4e4b-a219-4b4e6d3b3fed | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,218 | supabase-export-v2 | ba67c23cb34bb953 | :attr:`default_factory` attribute; it defaults to ``None``. All remaining arguments are treated the same as if they were passed to the :class:`dict` constructor, including keyword arguments.
:class:`defaultdict` objects support the following method in addition to the
standard :class:`dict` operations: | trusted_official_docs | CPython Docs | :attr:`default_factory` attribute; it defaults to ``None``. All remaining arguments are treated the same as if they were passed to the :class:`dict` constructor, including keyword arguments.
:class:`defaultdict` objects support the following method in addition to the
standard :class:`dict` operations: | :attr:`default_factory` attribute; it defaults to ``None``. All remaining arguments are treated the same as if they were passed to the :class:`dict` constructor, including keyword arguments.
:class:`defaultdict` objects support the following method in addition to the
standard :class:`dict` operations: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9b5893b4-c4dd-46c1-b190-718f8ffa92db | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,236 | supabase-export-v2 | 5b314421381764c7 | 'mississippi' >>> d = defaultdict(int) >>> for k in s: ... d[k] += 1 ... >>> sorted(d.items()) [('i', 4), ('m', 1), ('p', 2), ('s', 4)]
When a letter is first encountered, it is missing from the mapping, so the
:attr:`~defaultdict.default_factory` function calls :func:`int` to supply a default count of
zero. The increm... | trusted_official_docs | CPython Docs | 'mississippi' >>> d = defaultdict(int) >>> for k in s: ... d[k] += 1 ... >>> sorted(d.items()) [('i', 4), ('m', 1), ('p', 2), ('s', 4)]
When a letter is first encountered, it is missing from the mapping, so the
:attr:`~defaultdict.default_factory` function calls :func:`int` to supply a default count of
zero. The increm... | 'mississippi' >>> d = defaultdict(int) >>> for k in s: ... d[k] += 1 ... >>> sorted(d.items()) [('i', 4), ('m', 1), ('p', 2), ('s', 4)]
When a letter is first encountered, it is missing from the mapping, so the
:attr:`~defaultdict.default_factory` function calls :func:`int` to supply a default count of
zero. The increm... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9b978732-e5e6-458f-8d52-8fc86c480492 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,173 | supabase-export-v2 | 98a5e088180669ac | of the deque by appending elements from *iterable*. Note, the series of left appends results in reversing the order of elements in the iterable argument.
.. method:: index(value[, start[, stop]]) | trusted_official_docs | CPython Docs | of the deque by appending elements from *iterable*. Note, the series of left appends results in reversing the order of elements in the iterable argument.
.. method:: index(value[, start[, stop]]) | of the deque by appending elements from *iterable*. Note, the series of left appends results in reversing the order of elements in the iterable argument.
.. method:: index(value[, start[, stop]]) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9fb26057-7c30-4ce4-93c4-f9a73e3bd3a4 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,243 | supabase-export-v2 | a63032460f928736 | self-documenting code. They can be used wherever regular tuples are used, and they add the ability to access fields by name instead of position index.
.. function:: namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) | trusted_official_docs | CPython Docs | self-documenting code. They can be used wherever regular tuples are used, and they add the ability to access fields by name instead of position index.
.. function:: namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) | self-documenting code. They can be used wherever regular tuples are used, and they add the ability to access fields by name instead of position index.
.. function:: namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a24b5239-9c3f-439d-8553-7e96b08acc10 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,208 | supabase-export-v2 | bd591cec20c09179 | Another approach to using deques is to maintain a sequence of recently added elements by appending to the right and popping to the left::
def moving_average(iterable, n=3):
# moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0
# https://en.wikipedia.org/wiki/Moving_average
it = iter(iterable)
d = deque... | trusted_official_docs | CPython Docs | Another approach to using deques is to maintain a sequence of recently added elements by appending to the right and popping to the left::
def moving_average(iterable, n=3):
# moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0
# https://en.wikipedia.org/wiki/Moving_average
it = iter(iterable)
d = deque... | Another approach to using deques is to maintain a sequence of recently added elements by appending to the right and popping to the left::
def moving_average(iterable, n=3):
# moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0
# https://en.wikipedia.org/wiki/Moving_average
it = iter(iterable)
d = deque... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a6469555-3aee-4c09-b002-a40b7381aaaa | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,245 | supabase-export-v2 | cad6e6f85c3c5c00 | the subclass also have a helpful docstring (with *typename* and *field_names*) and a helpful :meth:`~object.__repr__` method which lists the tuple contents in a ``name=value`` format.
The *field_names* are a sequence of strings such as ``['x', 'y']``. Alternatively, *field_names* can be a single string with each fieldn... | trusted_official_docs | CPython Docs | the subclass also have a helpful docstring (with *typename* and *field_names*) and a helpful :meth:`~object.__repr__` method which lists the tuple contents in a ``name=value`` format.
The *field_names* are a sequence of strings such as ``['x', 'y']``. Alternatively, *field_names* can be a single string with each fieldn... | the subclass also have a helpful docstring (with *typename* and *field_names*) and a helpful :meth:`~object.__repr__` method which lists the tuple contents in a ``name=value`` format.
The *field_names* are a sequence of strings such as ``['x', 'y']``. Alternatively, *field_names* can be a single string with each fieldn... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a653f28c-7145-43cd-afdd-c139e0ba6ab6 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,101 | supabase-export-v2 | d013fc623a01f1c7 | Counter objects have a dictionary interface except that they return a zero count for missing items instead of raising a :exc:`KeyError`:
>>> c = Counter(['eggs', 'ham'])
>>> c['bacon'] # count of a missing element is zero
0 | trusted_official_docs | CPython Docs | Counter objects have a dictionary interface except that they return a zero count for missing items instead of raising a :exc:`KeyError`:
>>> c = Counter(['eggs', 'ham'])
>>> c['bacon'] # count of a missing element is zero
0 | Counter objects have a dictionary interface except that they return a zero count for missing items instead of raising a :exc:`KeyError`:
>>> c = Counter(['eggs', 'ham'])
>>> c['bacon'] # count of a missing element is zero
0 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a776e040-713b-4a53-bc11-02b7a4512a35 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,217 | supabase-export-v2 | d0c0f08182d89a67 | overrides one method and adds one writable instance variable. The remaining functionality is the same as for the :class:`dict` class and is not documented here.
The first argument provides the initial value for the :attr:`default_factory`
attribute; it defaults to ``None``. All remaining arguments are treated the same... | trusted_official_docs | CPython Docs | overrides one method and adds one writable instance variable. The remaining functionality is the same as for the :class:`dict` class and is not documented here.
The first argument provides the initial value for the :attr:`default_factory`
attribute; it defaults to ``None``. All remaining arguments are treated the same... | overrides one method and adds one writable instance variable. The remaining functionality is the same as for the :class:`dict` class and is not documented here.
The first argument provides the initial value for the :attr:`default_factory`
attribute; it defaults to ``None``. All remaining arguments are treated the same... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a8ee290d-2034-44c2-86aa-e5088c925b3d | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,320 | supabase-export-v2 | f3f0022f16bb090b | * :class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to efficiently reposition an element to an endpoint.
A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k,
last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its
associated value to the rightmost (last) position. | trusted_official_docs | CPython Docs | * :class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to efficiently reposition an element to an endpoint.
A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k,
last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its
associated value to the rightmost (last) position. | * :class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to efficiently reposition an element to an endpoint.
A regular :class:`dict` can emulate OrderedDict's ``od.move_to_end(k,
last=True)`` with ``d[k] = d.pop(k)`` which will move the key and its
associated value to the rightmost (last) position. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a9792de1-67f3-4455-9e7b-a430c850d3b4 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,213 | supabase-export-v2 | d735179dea12e86e | def delete_nth(d, n): d.rotate(-n) d.popleft() d.rotate(n)
To implement :class:`deque` slicing, use a similar approach applying
:meth:`~deque.rotate` to bring a target element to the left side of the deque. Remove
old entries with :meth:`~deque.popleft`, add new entries with :meth:`~deque.extend`, and then
reverse the ... | trusted_official_docs | CPython Docs | def delete_nth(d, n): d.rotate(-n) d.popleft() d.rotate(n)
To implement :class:`deque` slicing, use a similar approach applying
:meth:`~deque.rotate` to bring a target element to the left side of the deque. Remove
old entries with :meth:`~deque.popleft`, add new entries with :meth:`~deque.extend`, and then
reverse the ... | def delete_nth(d, n): d.rotate(-n) d.popleft() d.rotate(n)
To implement :class:`deque` slicing, use a similar approach applying
:meth:`~deque.rotate` to bring a target element to the left side of the deque. Remove
old entries with :meth:`~deque.popleft`, add new entries with :meth:`~deque.extend`, and then
reverse the ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
abd8f880-fc3e-4197-9c31-a455949c9596 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,130 | supabase-export-v2 | 37594e95c0b5a02d | cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs c.most_common()[:-n-1:-1] # n least common elements +c # remove zero and negative counts
Several mathematical operations are provided for combining :class:`Counter`
objects to produce multisets (counters that have counts greater than zer... | trusted_official_docs | CPython Docs | cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs c.most_common()[:-n-1:-1] # n least common elements +c # remove zero and negative counts
Several mathematical operations are provided for combining :class:`Counter`
objects to produce multisets (counters that have counts greater than zer... | cnt) pairs Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs c.most_common()[:-n-1:-1] # n least common elements +c # remove zero and negative counts
Several mathematical operations are provided for combining :class:`Counter`
objects to produce multisets (counters that have counts greater than zer... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ac877ea7-dae3-4ae5-9276-b8c8d3c5b1c7 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,342 | supabase-export-v2 | bd5e571601227346 | order the keys were *last* inserted. If a new entry overwrites an existing entry, the original insertion position is changed and moved to the end::
class LastUpdatedOrderedDict(OrderedDict):
'Store items in the order that the keys were last updated.' | trusted_official_docs | CPython Docs | order the keys were *last* inserted. If a new entry overwrites an existing entry, the original insertion position is changed and moved to the end::
class LastUpdatedOrderedDict(OrderedDict):
'Store items in the order that the keys were last updated.' | order the keys were *last* inserted. If a new entry overwrites an existing entry, the original insertion position is changed and moved to the end::
class LastUpdatedOrderedDict(OrderedDict):
'Store items in the order that the keys were last updated.' | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b196160c-b4d3-4c70-ac34-ab61815331a3 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,223 | supabase-export-v2 | 71b292b6091acc08 | If calling :attr:`default_factory` raises an exception this exception is propagated unchanged.
This method is called by the :meth:`~object.__getitem__` method of the
:class:`dict` class when the requested key is not found; whatever it
returns or raises is then returned or raised by :meth:`~object.__getitem__`. | trusted_official_docs | CPython Docs | If calling :attr:`default_factory` raises an exception this exception is propagated unchanged.
This method is called by the :meth:`~object.__getitem__` method of the
:class:`dict` class when the requested key is not found; whatever it
returns or raises is then returned or raised by :meth:`~object.__getitem__`. | If calling :attr:`default_factory` raises an exception this exception is propagated unchanged.
This method is called by the :meth:`~object.__getitem__` method of the
:class:`dict` class when the requested key is not found; whatever it
returns or raises is then returned or raised by :meth:`~object.__getitem__`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b23cfd77-c927-4ca8-99c0-238c16f0bff9 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,372 | supabase-export-v2 | f4cd7d7d4055ef3c | .. class:: UserList([list])
Class that simulates a list. The instance's contents are kept in a regular
list, which is accessible via the :attr:`data` attribute of :class:`UserList`
instances. The instance's contents are initially set to a copy of *list*,
defaulting to the empty list ``[]``. *list* can be any iterabl... | trusted_official_docs | CPython Docs | .. class:: UserList([list])
Class that simulates a list. The instance's contents are kept in a regular
list, which is accessible via the :attr:`data` attribute of :class:`UserList`
instances. The instance's contents are initially set to a copy of *list*,
defaulting to the empty list ``[]``. *list* can be any iterabl... | .. class:: UserList([list])
Class that simulates a list. The instance's contents are kept in a regular
list, which is accessible via the :attr:`data` attribute of :class:`UserList`
instances. The instance's contents are initially set to a copy of *list*,
defaulting to the empty list ``[]``. *list* can be any iterabl... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b59b18f8-83ac-441e-bcb8-e7cf859486f1 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,098 | supabase-export-v2 | 93501acb11de1439 | Counts are allowed to be any integer value including zero or negative counts. The :class:`Counter` class is similar to bags or multisets in other languages.
Elements are counted from an *iterable* or initialized from another
*mapping* (or counter): | trusted_official_docs | CPython Docs | Counts are allowed to be any integer value including zero or negative counts. The :class:`Counter` class is similar to bags or multisets in other languages.
Elements are counted from an *iterable* or initialized from another
*mapping* (or counter): | Counts are allowed to be any integer value including zero or negative counts. The :class:`Counter` class is similar to bags or multisets in other languages.
Elements are counted from an *iterable* or initialized from another
*mapping* (or counter): | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b6684e87-7a9e-4b1c-9995-189f9710a723 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,262 | supabase-export-v2 | e1b8d2897a2f45c2 | import csv for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv", "rb"))): print(emp.name, emp.title)
import sqlite3
conn = sqlite3.connect('/companydata')
cursor = conn.cursor()
cursor.execute('SELECT name, age, title, department, paygrade FROM employees')
for emp in map(EmployeeRecord._make, cursor... | trusted_official_docs | CPython Docs | import csv for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv", "rb"))): print(emp.name, emp.title)
import sqlite3
conn = sqlite3.connect('/companydata')
cursor = conn.cursor()
cursor.execute('SELECT name, age, title, department, paygrade FROM employees')
for emp in map(EmployeeRecord._make, cursor... | import csv for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv", "rb"))): print(emp.name, emp.title)
import sqlite3
conn = sqlite3.connect('/companydata')
cursor = conn.cursor()
cursor.execute('SELECT name, age, title, department, paygrade FROM employees')
for emp in map(EmployeeRecord._make, cursor... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b67de1c3-c073-4ac4-8311-b83d3e3360d2 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,369 | supabase-export-v2 | ce1fb982767c3305 | :class:`UserList` objects -------------------------
This class acts as a wrapper around list objects. It is a useful base class
for your own list-like classes which can inherit from them and override
existing methods or add new ones. In this way, one can add new behaviors to
lists. | trusted_official_docs | CPython Docs | :class:`UserList` objects -------------------------
This class acts as a wrapper around list objects. It is a useful base class
for your own list-like classes which can inherit from them and override
existing methods or add new ones. In this way, one can add new behaviors to
lists. | :class:`UserList` objects -------------------------
This class acts as a wrapper around list objects. It is a useful base class
for your own list-like classes which can inherit from them and override
existing methods or add new ones. In this way, one can add new behaviors to
lists. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b7b76899-9ff4-48f8-aaae-a2d7bfb83c55 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,238 | supabase-export-v2 | e805fb3234a8597d | A faster and more flexible way to create constant functions is to use a lambda function which can supply any constant value (not just zero):
>>> def constant_factory(value):
... return lambda: value
... >>> d = defaultdict(constant_factory('<missing>'))
>>> d.update(name='John', action='ran')
>>> '%(name)s %(action... | trusted_official_docs | CPython Docs | A faster and more flexible way to create constant functions is to use a lambda function which can supply any constant value (not just zero):
>>> def constant_factory(value):
... return lambda: value
... >>> d = defaultdict(constant_factory('<missing>'))
>>> d.update(name='John', action='ran')
>>> '%(name)s %(action... | A faster and more flexible way to create constant functions is to use a lambda function which can supply any constant value (not just zero):
>>> def constant_factory(value):
... return lambda: value
... >>> d = defaultdict(constant_factory('<missing>'))
>>> d.update(name='John', action='ran')
>>> '%(name)s %(action... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b7d3f9fd-2dab-43f5-b1f7-4ab66c23f6dc | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,284 | supabase-export-v2 | 22b6d772a5c9a5bf | >>> p._fields # view the field names ('x', 'y')
>>> Color = namedtuple('Color', 'red green blue')
>>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)
>>> Pixel(11, 22, 128, 255, 0)
Pixel(x=11, y=22, red=128, green=255, blue=0) | trusted_official_docs | CPython Docs | >>> p._fields # view the field names ('x', 'y')
>>> Color = namedtuple('Color', 'red green blue')
>>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)
>>> Pixel(11, 22, 128, 255, 0)
Pixel(x=11, y=22, red=128, green=255, blue=0) | >>> p._fields # view the field names ('x', 'y')
>>> Color = namedtuple('Color', 'red green blue')
>>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)
>>> Pixel(11, 22, 128, 255, 0)
Pixel(x=11, y=22, red=128, green=255, blue=0) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b8313d6f-804a-498c-b7d0-f30f666dd247 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,289 | supabase-export-v2 | 54eb65e003472cbb | >>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0]) >>> Account._field_defaults {'balance': 0} >>> Account('premium') Account(type='premium', balance=0)
To retrieve a field whose name is stored in a string, use the :func:`getattr`
function: | trusted_official_docs | CPython Docs | >>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0]) >>> Account._field_defaults {'balance': 0} >>> Account('premium') Account(type='premium', balance=0)
To retrieve a field whose name is stored in a string, use the :func:`getattr`
function: | >>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0]) >>> Account._field_defaults {'balance': 0} >>> Account('premium') Account(type='premium', balance=0)
To retrieve a field whose name is stored in a string, use the :func:`getattr`
function: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b9210eea-626e-470c-b20e-b4aaa959dde2 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,235 | supabase-export-v2 | c6e74678944a4bdb | Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :class:`defaultdict` useful for counting (like a bag or multiset in other languages):
>>> s = 'mississippi'
>>> d = defaultdict(int)
>>> for k in s:
... d[k] += 1
... >>> sorted(d.items())
[('i', 4), ('m', 1), ('p', 2), ('s', 4)] | trusted_official_docs | CPython Docs | Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :class:`defaultdict` useful for counting (like a bag or multiset in other languages):
>>> s = 'mississippi'
>>> d = defaultdict(int)
>>> for k in s:
... d[k] += 1
... >>> sorted(d.items())
[('i', 4), ('m', 1), ('p', 2), ('s', 4)] | Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :class:`defaultdict` useful for counting (like a bag or multiset in other languages):
>>> s = 'mississippi'
>>> d = defaultdict(int)
>>> for k in s:
... d[k] += 1
... >>> sorted(d.items())
[('i', 4), ('m', 1), ('p', 2), ('s', 4)] | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bbe09363-f5e3-4193-858d-4eab37821137 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,234 | supabase-export-v2 | 84448ad2851d79b9 | >>> d = {} >>> for k, v in s: ... d.setdefault(k, []).append(v) ... >>> sorted(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the
:class:`defaultdict` useful for counting (like a bag or multiset in other
languages): | trusted_official_docs | CPython Docs | >>> d = {} >>> for k, v in s: ... d.setdefault(k, []).append(v) ... >>> sorted(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the
:class:`defaultdict` useful for counting (like a bag or multiset in other
languages): | >>> d = {} >>> for k, v in s: ... d.setdefault(k, []).append(v) ... >>> sorted(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the
:class:`defaultdict` useful for counting (like a bag or multiset in other
languages): | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bd3d5520-84f2-4e12-a660-ab920e4b3bdc | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,357 | supabase-export-v2 | 8848daa072aff8b0 | .. doctest:: :hide:
>>> def square(x):
... return x * x
... >>> f = MultiHitLRUCache(square, maxsize=4, maxrequests=6)
>>> list(map(f, range(10))) # First requests, don't cache
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
>>> f(4) # Cache the second request
16
>>> f(6) # Cache the second request
36
>>> f(2) # The firs... | trusted_official_docs | CPython Docs | .. doctest:: :hide:
>>> def square(x):
... return x * x
... >>> f = MultiHitLRUCache(square, maxsize=4, maxrequests=6)
>>> list(map(f, range(10))) # First requests, don't cache
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
>>> f(4) # Cache the second request
16
>>> f(6) # Cache the second request
36
>>> f(2) # The firs... | .. doctest:: :hide:
>>> def square(x):
... return x * x
... >>> f = MultiHitLRUCache(square, maxsize=4, maxrequests=6)
>>> list(map(f, range(10))) # First requests, don't cache
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
>>> f(4) # Cache the second request
16
>>> f(6) # Cache the second request
36
>>> f(2) # The firs... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bedd3806-465f-4a2d-8325-50f1b29d2881 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,083 | supabase-export-v2 | 34186ce306577963 | parser = argparse.ArgumentParser() parser.add_argument('-u', '--user') parser.add_argument('-c', '--color') namespace = parser.parse_args() command_line_args = {k: v for k, v in vars(namespace).items() if v is not None}
combined = ChainMap(command_line_args, os.environ, defaults)
print(combined['color'])
print(combin... | trusted_official_docs | CPython Docs | parser = argparse.ArgumentParser() parser.add_argument('-u', '--user') parser.add_argument('-c', '--color') namespace = parser.parse_args() command_line_args = {k: v for k, v in vars(namespace).items() if v is not None}
combined = ChainMap(command_line_args, os.environ, defaults)
print(combined['color'])
print(combin... | parser = argparse.ArgumentParser() parser.add_argument('-u', '--user') parser.add_argument('-c', '--color') namespace = parser.parse_args() command_line_args = {k: v for k, v in vars(namespace).items() if v is not None}
combined = ChainMap(command_line_args, os.environ, defaults)
print(combined['color'])
print(combin... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c3322569-44d3-4c22-b3f2-f23891d8d9e2 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,249 | supabase-export-v2 | 69cfcef92b0ae1d1 | 'z']`` and the defaults are ``(1, 2)``, then ``x`` will be a required argument, ``y`` will default to ``1``, and ``z`` will default to ``2``.
If *module* is defined, the :attr:`~type.__module__` attribute of the
named tuple is set to that value. | trusted_official_docs | CPython Docs | 'z']`` and the defaults are ``(1, 2)``, then ``x`` will be a required argument, ``y`` will default to ``1``, and ``z`` will default to ``2``.
If *module* is defined, the :attr:`~type.__module__` attribute of the
named tuple is set to that value. | 'z']`` and the defaults are ``(1, 2)``, then ``x`` will be a required argument, ``y`` will default to ``1``, and ``z`` will default to ``2``.
If *module* is defined, the :attr:`~type.__module__` attribute of the
named tuple is set to that value. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c51025de-e65a-4000-8c78-2447569529ee | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,327 | supabase-export-v2 | 554f4e1da2c7a7c6 | .. method:: popitem(last=True)
The :meth:`popitem` method for ordered dictionaries returns and removes a
(key, value) pair. The pairs are returned in
:abbr:`LIFO (last-in, first-out)` order if *last* is true
or :abbr:`FIFO (first-in, first-out)` order if false. | trusted_official_docs | CPython Docs | .. method:: popitem(last=True)
The :meth:`popitem` method for ordered dictionaries returns and removes a
(key, value) pair. The pairs are returned in
:abbr:`LIFO (last-in, first-out)` order if *last* is true
or :abbr:`FIFO (first-in, first-out)` order if false. | .. method:: popitem(last=True)
The :meth:`popitem` method for ordered dictionaries returns and removes a
(key, value) pair. The pairs are returned in
:abbr:`LIFO (last-in, first-out)` order if *last* is true
or :abbr:`FIFO (first-in, first-out)` order if false. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c6a4d95a-0be0-4d2f-b28d-26e2533984fb | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,108 | supabase-export-v2 | fa268320a62fef01 | .. method:: elements()
Return an iterator over elements repeating each as many times as its
count. Elements are returned in the order first encountered. If an
element's count is less than one, :meth:`elements` will ignore it. | trusted_official_docs | CPython Docs | .. method:: elements()
Return an iterator over elements repeating each as many times as its
count. Elements are returned in the order first encountered. If an
element's count is less than one, :meth:`elements` will ignore it. | .. method:: elements()
Return an iterator over elements repeating each as many times as its
count. Elements are returned in the order first encountered. If an
element's count is less than one, :meth:`elements` will ignore it. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c7556d64-0234-466c-865f-6a425e69eced | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,082 | supabase-export-v2 | 4f248101dbe4aecc | defaults = {'color': 'red', 'user': 'guest'}
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--user')
parser.add_argument('-c', '--color')
namespace = parser.parse_args()
command_line_args = {k: v for k, v in vars(namespace).items() if v is not None} | trusted_official_docs | CPython Docs | defaults = {'color': 'red', 'user': 'guest'}
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--user')
parser.add_argument('-c', '--color')
namespace = parser.parse_args()
command_line_args = {k: v for k, v in vars(namespace).items() if v is not None} | defaults = {'color': 'red', 'user': 'guest'}
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--user')
parser.add_argument('-c', '--color')
namespace = parser.parse_args()
command_line_args = {k: v for k, v in vars(namespace).items() if v is not None} | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c78f4183-f77b-41b5-be45-9b8a618c5458 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,360 | supabase-export-v2 | 31f7dd0343bccfa6 | the ability to subclass directly from :class:`dict`; however, this class can be easier to work with because the underlying dictionary is accessible as an attribute.
.. class:: UserDict(**kwargs)
UserDict(mapping, /, **kwargs)
UserDict(iterable, /, **kwargs) | trusted_official_docs | CPython Docs | the ability to subclass directly from :class:`dict`; however, this class can be easier to work with because the underlying dictionary is accessible as an attribute.
.. class:: UserDict(**kwargs)
UserDict(mapping, /, **kwargs)
UserDict(iterable, /, **kwargs) | the ability to subclass directly from :class:`dict`; however, this class can be easier to work with because the underlying dictionary is accessible as an attribute.
.. class:: UserDict(**kwargs)
UserDict(mapping, /, **kwargs)
UserDict(iterable, /, **kwargs) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c830bf10-921c-4946-9636-ef292fa701ff | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,221 | supabase-export-v2 | 9a698cef99383196 | If the :attr:`default_factory` attribute is ``None``, this raises a :exc:`KeyError` exception with the *key* as argument.
If :attr:`default_factory` is not ``None``, it is called without arguments
to provide a default value for the given *key*, this value is inserted in
the dictionary for the *key*, and returned. | trusted_official_docs | CPython Docs | If the :attr:`default_factory` attribute is ``None``, this raises a :exc:`KeyError` exception with the *key* as argument.
If :attr:`default_factory` is not ``None``, it is called without arguments
to provide a default value for the given *key*, this value is inserted in
the dictionary for the *key*, and returned. | If the :attr:`default_factory` attribute is ``None``, this raises a :exc:`KeyError` exception with the *key* as argument.
If :attr:`default_factory` is not ``None``, it is called without arguments
to provide a default value for the given *key*, this value is inserted in
the dictionary for the *key*, and returned. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c84ab7ef-e250-4b11-a45c-bcfd858f1cc4 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,207 | supabase-export-v2 | 8aed613a6a3db4a5 | def tail(filename, n=10): 'Return the last n lines of a file' with open(filename) as f: return deque(f, n)
Another approach to using deques is to maintain a sequence of recently
added elements by appending to the right and popping to the left:: | trusted_official_docs | CPython Docs | def tail(filename, n=10): 'Return the last n lines of a file' with open(filename) as f: return deque(f, n)
Another approach to using deques is to maintain a sequence of recently
added elements by appending to the right and popping to the left:: | def tail(filename, n=10): 'Return the last n lines of a file' with open(filename) as f: return deque(f, n)
Another approach to using deques is to maintain a sequence of recently
added elements by appending to the right and popping to the left:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ca6983f9-c44d-4e34-9282-a761e9ee4e26 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,341 | supabase-export-v2 | 45a29c759e2a7b93 | :class:`OrderedDict` Examples and Recipes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is straightforward to create an ordered dictionary variant
that remembers the order the keys were *last* inserted. If a new entry overwrites an existing entry, the
original insertion position is changed and moved to the end:: | trusted_official_docs | CPython Docs | :class:`OrderedDict` Examples and Recipes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is straightforward to create an ordered dictionary variant
that remembers the order the keys were *last* inserted. If a new entry overwrites an existing entry, the
original insertion position is changed and moved to the end:: | :class:`OrderedDict` Examples and Recipes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is straightforward to create an ordered dictionary variant
that remembers the order the keys were *last* inserted. If a new entry overwrites an existing entry, the
original insertion position is changed and moved to the end:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
caf59175-4004-4090-bbd9-9d56476a571c | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,198 | supabase-export-v2 | 2c62e9143faf9a7d | deque('ghi') # make a new deque with three items >>> for elem in d: # iterate over the deque's elements ... print(elem.upper()) G H I
>>> d.append('j') # add a new entry to the right side
>>> d.appendleft('f') # add a new entry to the left side
>>> d # show the representation of the deque
deque(['f', 'g', 'h', 'i', ... | trusted_official_docs | CPython Docs | deque('ghi') # make a new deque with three items >>> for elem in d: # iterate over the deque's elements ... print(elem.upper()) G H I
>>> d.append('j') # add a new entry to the right side
>>> d.appendleft('f') # add a new entry to the left side
>>> d # show the representation of the deque
deque(['f', 'g', 'h', 'i', ... | deque('ghi') # make a new deque with three items >>> for elem in d: # iterate over the deque's elements ... print(elem.upper()) G H I
>>> d.append('j') # add a new entry to the right side
>>> d.appendleft('f') # add a new entry to the left side
>>> d # show the representation of the deque
deque(['f', 'g', 'h', 'i', ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cca0549c-ccd2-40f1-99ed-1f5d640a8217 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,298 | supabase-export-v2 | 60ceead4f80aa834 | The subclass shown above sets ``__slots__`` to an empty tuple. This helps keep memory requirements low by preventing the creation of instance dictionaries.
Subclassing is not useful for adding new, stored fields. Instead, simply
create a new named tuple type from the :attr:`~somenamedtuple._fields` attribute: | trusted_official_docs | CPython Docs | The subclass shown above sets ``__slots__`` to an empty tuple. This helps keep memory requirements low by preventing the creation of instance dictionaries.
Subclassing is not useful for adding new, stored fields. Instead, simply
create a new named tuple type from the :attr:`~somenamedtuple._fields` attribute: | The subclass shown above sets ``__slots__`` to an empty tuple. This helps keep memory requirements low by preventing the creation of instance dictionaries.
Subclassing is not useful for adding new, stored fields. Instead, simply
create a new named tuple type from the :attr:`~somenamedtuple._fields` attribute: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cdc029f1-9967-4e75-a85c-dfc6e4ca32fb | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,233 | supabase-export-v2 | 7b7ebf8473778364 | for that key) and the :meth:`list.append` operation adds another value to the list. This technique is simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
>>> d = {}
>>> for k, v in s:
... d.setdefault(k, []).append(v)
... >>> sorted(d.items())
[('blue', [2, 4]), ('red', [1]), ('yellow', [... | trusted_official_docs | CPython Docs | for that key) and the :meth:`list.append` operation adds another value to the list. This technique is simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
>>> d = {}
>>> for k, v in s:
... d.setdefault(k, []).append(v)
... >>> sorted(d.items())
[('blue', [2, 4]), ('red', [1]), ('yellow', [... | for that key) and the :meth:`list.append` operation adds another value to the list. This technique is simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
>>> d = {}
>>> for k, v in s:
... d.setdefault(k, []).append(v)
... >>> sorted(d.items())
[('blue', [2, 4]), ('red', [1]), ('yellow', [... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d2292be9-f1ed-469b-9af3-c0c4925c96f9 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,065 | supabase-export-v2 | 2d11553123202f01 | used in :term:`nested scopes <nested scope>`. The use cases also parallel those for the built-in :func:`super` function. A reference to ``d.parents`` is equivalent to: ``ChainMap(*d.maps[1:])``.
Note, the iteration order of a :class:`ChainMap` is determined by
scanning the mappings last to first:: | trusted_official_docs | CPython Docs | used in :term:`nested scopes <nested scope>`. The use cases also parallel those for the built-in :func:`super` function. A reference to ``d.parents`` is equivalent to: ``ChainMap(*d.maps[1:])``.
Note, the iteration order of a :class:`ChainMap` is determined by
scanning the mappings last to first:: | used in :term:`nested scopes <nested scope>`. The use cases also parallel those for the built-in :func:`super` function. A reference to ``d.parents`` is equivalent to: ``ChainMap(*d.maps[1:])``.
Note, the iteration order of a :class:`ChainMap` is determined by
scanning the mappings last to first:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d46f7458-ae69-497c-995c-c962b025bcff | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,309 | supabase-export-v2 | fa1321153024d3db | :class:`OrderedDict` objects ----------------------------
Ordered dictionaries are just like regular dictionaries but have some extra
capabilities relating to ordering operations. They have become less
important now that the built-in :class:`dict` class gained the ability
to remember insertion order (this new behavior ... | trusted_official_docs | CPython Docs | :class:`OrderedDict` objects ----------------------------
Ordered dictionaries are just like regular dictionaries but have some extra
capabilities relating to ordering operations. They have become less
important now that the built-in :class:`dict` class gained the ability
to remember insertion order (this new behavior ... | :class:`OrderedDict` objects ----------------------------
Ordered dictionaries are just like regular dictionaries but have some extra
capabilities relating to ordering operations. They have become less
important now that the built-in :class:`dict` class gained the ability
to remember insertion order (this new behavior ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
da04f1c0-c3f4-471d-8cc8-f139c6b13299 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,086 | supabase-export-v2 | 99e4568cf5de0b9d | # Current context dictionary -- like Python's locals() e.maps[-1] # Root context -- like Python's globals() e.parents # Enclosing context chain -- like Python's nonlocals
d['x'] = 1 # Set value in current context
d['x'] # Get first key in the chain of contexts
del d['x'] # Delete from current context
list(d) # All n... | trusted_official_docs | CPython Docs | # Current context dictionary -- like Python's locals() e.maps[-1] # Root context -- like Python's globals() e.parents # Enclosing context chain -- like Python's nonlocals
d['x'] = 1 # Set value in current context
d['x'] # Get first key in the chain of contexts
del d['x'] # Delete from current context
list(d) # All n... | # Current context dictionary -- like Python's locals() e.maps[-1] # Root context -- like Python's globals() e.parents # Enclosing context chain -- like Python's nonlocals
d['x'] = 1 # Set value in current context
d['x'] # Get first key in the chain of contexts
del d['x'] # Delete from current context
list(d) # All n... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dbc1cf6b-3bc7-44b5-96af-2b3f19d52d8f | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,232 | supabase-export-v2 | 7cec29b3a7f4cc42 | ('red', 1)] >>> d = defaultdict(list) >>> for k, v in s: ... d[k].append(v) ... >>> sorted(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
When each key is encountered for the first time, it is not already in the
mapping; so an entry is automatically created using the :attr:`~defaultdict.default_factory... | trusted_official_docs | CPython Docs | ('red', 1)] >>> d = defaultdict(list) >>> for k, v in s: ... d[k].append(v) ... >>> sorted(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
When each key is encountered for the first time, it is not already in the
mapping; so an entry is automatically created using the :attr:`~defaultdict.default_factory... | ('red', 1)] >>> d = defaultdict(list) >>> for k, v in s: ... d[k].append(v) ... >>> sorted(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
When each key is encountered for the first time, it is not already in the
mapping; so an entry is automatically created using the :attr:`~defaultdict.default_factory... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dbdeef72-6f24-43f6-aebc-872e96dc46f6 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,201 | supabase-export-v2 | b30d8445d4355a01 | d.rotate(1) # right rotation >>> d deque(['l', 'g', 'h', 'i', 'j', 'k']) >>> d.rotate(-1) # left rotation >>> d deque(['g', 'h', 'i', 'j', 'k', 'l'])
>>> deque(reversed(d)) # make a new deque in reverse order
deque(['l', 'k', 'j', 'i', 'h', 'g'])
>>> d.clear() # empty the deque
>>> d.pop() # cannot pop from an empty... | trusted_official_docs | CPython Docs | d.rotate(1) # right rotation >>> d deque(['l', 'g', 'h', 'i', 'j', 'k']) >>> d.rotate(-1) # left rotation >>> d deque(['g', 'h', 'i', 'j', 'k', 'l'])
>>> deque(reversed(d)) # make a new deque in reverse order
deque(['l', 'k', 'j', 'i', 'h', 'g'])
>>> d.clear() # empty the deque
>>> d.pop() # cannot pop from an empty... | d.rotate(1) # right rotation >>> d deque(['l', 'g', 'h', 'i', 'j', 'k']) >>> d.rotate(-1) # left rotation >>> d deque(['g', 'h', 'i', 'j', 'k', 'l'])
>>> deque(reversed(d)) # make a new deque in reverse order
deque(['l', 'k', 'j', 'i', 'h', 'g'])
>>> d.clear() # empty the deque
>>> d.pop() # cannot pop from an empty... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dc67c1a1-749b-4f21-8680-ac0c47de47c0 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,058 | supabase-export-v2 | be7e6f5ee7721425 | .. attribute:: maps
A user updateable list of mappings. The list is ordered from
first-searched to last-searched. It is the only stored state and can
be modified to change which mappings are searched. The list should
always contain at least one mapping. | trusted_official_docs | CPython Docs | .. attribute:: maps
A user updateable list of mappings. The list is ordered from
first-searched to last-searched. It is the only stored state and can
be modified to change which mappings are searched. The list should
always contain at least one mapping. | .. attribute:: maps
A user updateable list of mappings. The list is ordered from
first-searched to last-searched. It is the only stored state and can
be modified to change which mappings are searched. The list should
always contain at least one mapping. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dd18d740-56e7-4ee2-b675-b7ce1d5b09f1 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,094 | supabase-export-v2 | 37af9e64af11dc88 | A counter tool is provided to support convenient and rapid tallies. For example::
>>> # Tally occurrences of words in a list
>>> cnt = Counter()
>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
... cnt[word] += 1
... >>> cnt
Counter({'blue': 3, 'red': 2, 'green': 1}) | trusted_official_docs | CPython Docs | A counter tool is provided to support convenient and rapid tallies. For example::
>>> # Tally occurrences of words in a list
>>> cnt = Counter()
>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
... cnt[word] += 1
... >>> cnt
Counter({'blue': 3, 'red': 2, 'green': 1}) | A counter tool is provided to support convenient and rapid tallies. For example::
>>> # Tally occurrences of words in a list
>>> cnt = Counter()
>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
... cnt[word] += 1
... >>> cnt
Counter({'blue': 3, 'red': 2, 'green': 1}) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dfe79eee-fad7-4d60-8367-d0cb03ef49d1 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,132 | supabase-export-v2 | 2b111fcf3c75b790 | .. doctest::
>>> c = Counter(a=3, b=1)
>>> d = Counter(a=1, b=2)
>>> c + d # add two counters together: c[x] + d[x]
Counter({'a': 4, 'b': 3})
>>> c - d # subtract (keeping only positive counts)
Counter({'a': 2})
>>> c & d # intersection: min(c[x], d[x])
Counter({'a': 1, 'b': 1})
>>> c | d # union: max(c[x], d[x... | trusted_official_docs | CPython Docs | .. doctest::
>>> c = Counter(a=3, b=1)
>>> d = Counter(a=1, b=2)
>>> c + d # add two counters together: c[x] + d[x]
Counter({'a': 4, 'b': 3})
>>> c - d # subtract (keeping only positive counts)
Counter({'a': 2})
>>> c & d # intersection: min(c[x], d[x])
Counter({'a': 1, 'b': 1})
>>> c | d # union: max(c[x], d[x... | .. doctest::
>>> c = Counter(a=3, b=1)
>>> d = Counter(a=1, b=2)
>>> c + d # add two counters together: c[x] + d[x]
Counter({'a': 4, 'b': 3})
>>> c - d # subtract (keeping only positive counts)
Counter({'a': 2})
>>> c & d # intersection: min(c[x], d[x])
Counter({'a': 1, 'b': 1})
>>> c | d # union: max(c[x], d[x... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e7dd44fe-0fd3-4ea1-baa2-8c41744fd007 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,381 | supabase-export-v2 | 17754e731859e015 | .. class:: UserString(seq)
Class that simulates a string object. The instance's
content is kept in a regular string object, which is accessible via the
:attr:`data` attribute of :class:`UserString` instances. The instance's
contents are initially set to a copy of *seq*. The *seq* argument can
be any object which ca... | trusted_official_docs | CPython Docs | .. class:: UserString(seq)
Class that simulates a string object. The instance's
content is kept in a regular string object, which is accessible via the
:attr:`data` attribute of :class:`UserString` instances. The instance's
contents are initially set to a copy of *seq*. The *seq* argument can
be any object which ca... | .. class:: UserString(seq)
Class that simulates a string object. The instance's
content is kept in a regular string object, which is accessible via the
:attr:`data` attribute of :class:`UserString` instances. The instance's
contents are initially set to a copy of *seq*. The *seq* argument can
be any object which ca... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e83ee108-d50d-439c-bc96-54fe8c6386ba | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,139 | supabase-export-v2 | cf59f9a64fc04b28 | unnecessarily preclude use cases needing other types or negative values. To help with those use cases, this section documents the minimum range and type restrictions.
* The :class:`Counter` class itself is a dictionary subclass with no
restrictions on its keys and values. The values are intended to be numbers
represe... | trusted_official_docs | CPython Docs | unnecessarily preclude use cases needing other types or negative values. To help with those use cases, this section documents the minimum range and type restrictions.
* The :class:`Counter` class itself is a dictionary subclass with no
restrictions on its keys and values. The values are intended to be numbers
represe... | unnecessarily preclude use cases needing other types or negative values. To help with those use cases, this section documents the minimum range and type restrictions.
* The :class:`Counter` class itself is a dictionary subclass with no
restrictions on its keys and values. The values are intended to be numbers
represe... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e8da6eab-6fca-413b-a533-a4c7d4e1324a | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,141 | supabase-export-v2 | 05c58bf4b06d29b2 | * The :meth:`~Counter.most_common` method requires only that the values be orderable.
* For in-place operations such as ``c[key] += 1``, the value type need only
support addition and subtraction. So fractions, floats, and decimals would
work and negative values are supported. The same is also true for
:meth:`~Counte... | trusted_official_docs | CPython Docs | * The :meth:`~Counter.most_common` method requires only that the values be orderable.
* For in-place operations such as ``c[key] += 1``, the value type need only
support addition and subtraction. So fractions, floats, and decimals would
work and negative values are supported. The same is also true for
:meth:`~Counte... | * The :meth:`~Counter.most_common` method requires only that the values be orderable.
* For in-place operations such as ``c[key] += 1``, the value type need only
support addition and subtraction. So fractions, floats, and decimals would
work and negative values are supported. The same is also true for
:meth:`~Counte... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e93f14fa-9e13-4296-a0b2-19faa0d0c9d5 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,209 | supabase-export-v2 | 5ac1d0389729223c | it = iter(iterable) d = deque(itertools.islice(it, n-1)) d.appendleft(0) s = sum(d) for elem in it: s += elem - d.popleft() d.append(elem) yield s / n
A `round-robin scheduler
<https://en.wikipedia.org/wiki/Round-robin_scheduling>`_ can be implemented with
input iterators stored in a :class:`deque`. Values are yielded ... | trusted_official_docs | CPython Docs | it = iter(iterable) d = deque(itertools.islice(it, n-1)) d.appendleft(0) s = sum(d) for elem in it: s += elem - d.popleft() d.append(elem) yield s / n
A `round-robin scheduler
<https://en.wikipedia.org/wiki/Round-robin_scheduling>`_ can be implemented with
input iterators stored in a :class:`deque`. Values are yielded ... | it = iter(iterable) d = deque(itertools.islice(it, n-1)) d.appendleft(0) s = sum(d) for elem in it: s += elem - d.popleft() d.append(elem) yield s / n
A `round-robin scheduler
<https://en.wikipedia.org/wiki/Round-robin_scheduling>`_ can be implemented with
input iterators stored in a :class:`deque`. Values are yielded ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ea14a523-25fa-4ab7-ba3a-c1ec69de7029 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,087 | supabase-export-v2 | 21d26d58bd6faaf5 | in d # Check all nested values len(d) # Number of nested values d.items() # All nested items dict(d) # Flatten into a regular dictionary
The :class:`ChainMap` class only makes updates (writes and deletions) to the
first mapping in the chain while lookups will search the full chain. However,
if deep writes and deletions... | trusted_official_docs | CPython Docs | in d # Check all nested values len(d) # Number of nested values d.items() # All nested items dict(d) # Flatten into a regular dictionary
The :class:`ChainMap` class only makes updates (writes and deletions) to the
first mapping in the chain while lookups will search the full chain. However,
if deep writes and deletions... | in d # Check all nested values len(d) # Number of nested values d.items() # All nested items dict(d) # Flatten into a regular dictionary
The :class:`ChainMap` class only makes updates (writes and deletions) to the
first mapping in the chain while lookups will search the full chain. However,
if deep writes and deletions... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eab47f71-6a54-40eb-8b82-b8cb84806cf2 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,142 | supabase-export-v2 | d3148ecdaf172010 | and negative values are supported. The same is also true for :meth:`~Counter.update` and :meth:`~Counter.subtract` which allow negative and zero values for both inputs and outputs.
* The multiset methods are designed only for use cases with positive values. The inputs may be negative or zero, but only outputs with posi... | trusted_official_docs | CPython Docs | and negative values are supported. The same is also true for :meth:`~Counter.update` and :meth:`~Counter.subtract` which allow negative and zero values for both inputs and outputs.
* The multiset methods are designed only for use cases with positive values. The inputs may be negative or zero, but only outputs with posi... | and negative values are supported. The same is also true for :meth:`~Counter.update` and :meth:`~Counter.subtract` which allow negative and zero values for both inputs and outputs.
* The multiset methods are designed only for use cases with positive values. The inputs may be negative or zero, but only outputs with posi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
eb02ae91-d19f-4691-bdfc-3582dc89b8eb | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,329 | supabase-export-v2 | df072339cce00e2e | .. method:: move_to_end(key, last=True)
Move an existing *key* to either end of an ordered dictionary. The item
is moved to the right end if *last* is true (the default) or to the
beginning if *last* is false. Raises :exc:`KeyError` if the *key* does
not exist: | trusted_official_docs | CPython Docs | .. method:: move_to_end(key, last=True)
Move an existing *key* to either end of an ordered dictionary. The item
is moved to the right end if *last* is true (the default) or to the
beginning if *last* is false. Raises :exc:`KeyError` if the *key* does
not exist: | .. method:: move_to_end(key, last=True)
Move an existing *key* to either end of an ordered dictionary. The item
is moved to the right end if *last* is true (the default) or to the
beginning if *last* is false. Raises :exc:`KeyError` if the *key* does
not exist: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f3b1fe06-e6d2-403f-bbf1-9e231fa8899e | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,195 | supabase-export-v2 | 044fe370001459ac | first element. Indexed access is *O*\ (1) at both ends but slows to *O*\ (*n*) in the middle. For fast random access, use lists instead.
Starting in version 3.5, deques support ``__add__()``, ``__mul__()``,
and ``__imul__()``. | trusted_official_docs | CPython Docs | first element. Indexed access is *O*\ (1) at both ends but slows to *O*\ (*n*) in the middle. For fast random access, use lists instead.
Starting in version 3.5, deques support ``__add__()``, ``__mul__()``,
and ``__imul__()``. | first element. Indexed access is *O*\ (1) at both ends but slows to *O*\ (*n*) in the middle. For fast random access, use lists instead.
Starting in version 3.5, deques support ``__add__()``, ``__mul__()``,
and ``__imul__()``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f3db7e3c-79d4-44c7-a5bb-ba6580dc0f6b | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,211 | supabase-export-v2 | e8199f316ed17f9f | D E B F C" iterators = deque(map(iter, iterables)) while iterators: try: while True: yield next(iterators[0]) iterators.rotate(-1) except StopIteration: # Remove an exhausted iterator. iterators.popleft()
The :meth:`~deque.rotate` method provides a way to implement :class:`deque` slicing and
deletion. For example, a pu... | trusted_official_docs | CPython Docs | D E B F C" iterators = deque(map(iter, iterables)) while iterators: try: while True: yield next(iterators[0]) iterators.rotate(-1) except StopIteration: # Remove an exhausted iterator. iterators.popleft()
The :meth:`~deque.rotate` method provides a way to implement :class:`deque` slicing and
deletion. For example, a pu... | D E B F C" iterators = deque(map(iter, iterables)) while iterators: try: while True: yield next(iterators[0]) iterators.rotate(-1) except StopIteration: # Remove an exhausted iterator. iterators.popleft()
The :meth:`~deque.rotate` method provides a way to implement :class:`deque` slicing and
deletion. For example, a pu... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f42e421d-2720-40a2-9152-a58a54eb0844 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,055 | supabase-export-v2 | 46516bc15efe1db6 | Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping.
A :class:`ChainMap` incorporates the underlying mappings by reference. So, if
one of the underlying mappings gets updated, those changes will be reflected
in :class:... | trusted_official_docs | CPython Docs | Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping.
A :class:`ChainMap` incorporates the underlying mappings by reference. So, if
one of the underlying mappings gets updated, those changes will be reflected
in :class:... | Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping.
A :class:`ChainMap` incorporates the underlying mappings by reference. So, if
one of the underlying mappings gets updated, those changes will be reflected
in :class:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f698ecd1-2cda-4cb4-aab5-f3130afa64fa | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,307 | supabase-export-v2 | b518afb3920cf84f | * See :meth:`types.SimpleNamespace` for a mutable namespace based on an underlying dictionary instead of a tuple.
* The :mod:`dataclasses` module provides a decorator and functions for
automatically adding generated special methods to user-defined classes. | trusted_official_docs | CPython Docs | * See :meth:`types.SimpleNamespace` for a mutable namespace based on an underlying dictionary instead of a tuple.
* The :mod:`dataclasses` module provides a decorator and functions for
automatically adding generated special methods to user-defined classes. | * See :meth:`types.SimpleNamespace` for a mutable namespace based on an underlying dictionary instead of a tuple.
* The :mod:`dataclasses` module provides a decorator and functions for
automatically adding generated special methods to user-defined classes. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f737435d-e825-404e-b39b-a34062699bbd | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,237 | supabase-export-v2 | fdf2b8028db5e5ad | mapping, so the :attr:`~defaultdict.default_factory` function calls :func:`int` to supply a default count of zero. The increment operation then builds up the count for each letter.
The function :func:`int` which always returns zero is just a special case of
constant functions. A faster and more flexible way to create c... | trusted_official_docs | CPython Docs | mapping, so the :attr:`~defaultdict.default_factory` function calls :func:`int` to supply a default count of zero. The increment operation then builds up the count for each letter.
The function :func:`int` which always returns zero is just a special case of
constant functions. A faster and more flexible way to create c... | mapping, so the :attr:`~defaultdict.default_factory` function calls :func:`int` to supply a default count of zero. The increment operation then builds up the count for each letter.
The function :func:`int` which always returns zero is just a special case of
constant functions. A faster and more flexible way to create c... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f99b2bea-f548-468c-a4b7-faf99b7f0db3 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,072 | supabase-export-v2 | ada1bce4bffb9125 | * The `MultiContext class <https://github.com/enthought/codetools/blob/4.0.0/codetools/contexts/multi_context.py>`_ in the Enthought `CodeTools package <https://github.com/enthought/codetools>`_ has options to support writing to any mapping in the chain.
* Django's `Context class
<https://github.com/django/django/blob... | trusted_official_docs | CPython Docs | * The `MultiContext class <https://github.com/enthought/codetools/blob/4.0.0/codetools/contexts/multi_context.py>`_ in the Enthought `CodeTools package <https://github.com/enthought/codetools>`_ has options to support writing to any mapping in the chain.
* Django's `Context class
<https://github.com/django/django/blob... | * The `MultiContext class <https://github.com/enthought/codetools/blob/4.0.0/codetools/contexts/multi_context.py>`_ in the Enthought `CodeTools package <https://github.com/enthought/codetools>`_ has options to support writing to any mapping in the chain.
* Django's `Context class
<https://github.com/django/django/blob... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f9c8b3e5-debc-4f80-a545-d24d57e3b8bb | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,313 | supabase-export-v2 | 417d1a910a3d844c | * The :class:`OrderedDict` was designed to be good at reordering operations. Space efficiency, iteration speed, and the performance of update operations were secondary.
* The :class:`OrderedDict` algorithm can handle frequent reordering operations
better than :class:`dict`. As shown in the recipes below, this makes it... | trusted_official_docs | CPython Docs | * The :class:`OrderedDict` was designed to be good at reordering operations. Space efficiency, iteration speed, and the performance of update operations were secondary.
* The :class:`OrderedDict` algorithm can handle frequent reordering operations
better than :class:`dict`. As shown in the recipes below, this makes it... | * The :class:`OrderedDict` was designed to be good at reordering operations. Space efficiency, iteration speed, and the performance of update operations were secondary.
* The :class:`OrderedDict` algorithm can handle frequent reordering operations
better than :class:`dict`. As shown in the recipes below, this makes it... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa6a3690-7680-44fb-9e79-904e5ca479a9 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,310 | supabase-export-v2 | 556a9b86fea96306 | have become less important now that the built-in :class:`dict` class gained the ability to remember insertion order (this new behavior became guaranteed in Python 3.7).
Some differences from :class:`dict` still remain: | trusted_official_docs | CPython Docs | have become less important now that the built-in :class:`dict` class gained the ability to remember insertion order (this new behavior became guaranteed in Python 3.7).
Some differences from :class:`dict` still remain: | have become less important now that the built-in :class:`dict` class gained the ability to remember insertion order (this new behavior became guaranteed in Python 3.7).
Some differences from :class:`dict` still remain: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa7e18b0-5cd3-4015-a088-eb36187e9f8b | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,305 | supabase-export-v2 | 7faf78f40cc18af4 | * See :class:`typing.NamedTuple` for a way to add type hints for named tuples. It also provides an elegant notation using the :keyword:`class` keyword::
class Component(NamedTuple):
part_number: int
weight: float
description: Optional[str] = None | trusted_official_docs | CPython Docs | * See :class:`typing.NamedTuple` for a way to add type hints for named tuples. It also provides an elegant notation using the :keyword:`class` keyword::
class Component(NamedTuple):
part_number: int
weight: float
description: Optional[str] = None | * See :class:`typing.NamedTuple` for a way to add type hints for named tuples. It also provides an elegant notation using the :keyword:`class` keyword::
class Component(NamedTuple):
part_number: int
weight: float
description: Optional[str] = None | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fadae74c-9bb1-4c46-aafc-80c41ad18b50 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,060 | supabase-export-v2 | fbd9b62f98cfdcd2 | .. method:: new_child(m=None, **kwargs)
Returns a new :class:`ChainMap` containing a new map followed by
all of the maps in the current instance. If ``m`` is specified,
it becomes the new map at the front of the list of mappings; if not
specified, an empty dict is used, so that a call to ``d.new_child()``
is equiva... | trusted_official_docs | CPython Docs | .. method:: new_child(m=None, **kwargs)
Returns a new :class:`ChainMap` containing a new map followed by
all of the maps in the current instance. If ``m`` is specified,
it becomes the new map at the front of the list of mappings; if not
specified, an empty dict is used, so that a call to ``d.new_child()``
is equiva... | .. method:: new_child(m=None, **kwargs)
Returns a new :class:`ChainMap` containing a new map followed by
all of the maps in the current instance. If ``m`` is specified,
it becomes the new map at the front of the list of mappings; if not
specified, an empty dict is used, so that a call to ``d.new_child()``
is equiva... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fb3990b4-a4fb-4b65-9c96-ddcf8033ca55 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,138 | supabase-export-v2 | a414f8e173ff176c | .. note::
Counters were primarily designed to work with positive integers to represent
running counts; however, care was taken to not unnecessarily preclude use
cases needing other types or negative values. To help with those use cases,
this section documents the minimum range and type restrictions. | trusted_official_docs | CPython Docs | .. note::
Counters were primarily designed to work with positive integers to represent
running counts; however, care was taken to not unnecessarily preclude use
cases needing other types or negative values. To help with those use cases,
this section documents the minimum range and type restrictions. | .. note::
Counters were primarily designed to work with positive integers to represent
running counts; however, care was taken to not unnecessarily preclude use
cases needing other types or negative values. To help with those use cases,
this section documents the minimum range and type restrictions. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fd38124f-ae68-401b-bc51-5ae1517e76b3 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,155 | supabase-export-v2 | ace668d5f64e8537 | queue"). Deques support thread-safe, memory efficient appends and pops from either side of the deque with approximately the same *O*\ (1) performance in either direction.
Though :class:`list` objects support similar operations, they are optimized for
fast fixed-length operations and incur *O*\ (*n*) memory movement co... | trusted_official_docs | CPython Docs | queue"). Deques support thread-safe, memory efficient appends and pops from either side of the deque with approximately the same *O*\ (1) performance in either direction.
Though :class:`list` objects support similar operations, they are optimized for
fast fixed-length operations and incur *O*\ (*n*) memory movement co... | queue"). Deques support thread-safe, memory efficient appends and pops from either side of the deque with approximately the same *O*\ (1) performance in either direction.
Though :class:`list` objects support similar operations, they are optimized for
fast fixed-length operations and incur *O*\ (*n*) memory movement co... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fd7f8efe-ca79-4a1a-a745-12097eb72510 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,197 | supabase-export-v2 | cb5c6a50031c1fae | .. doctest::
>>> from collections import deque
>>> d = deque('ghi') # make a new deque with three items
>>> for elem in d: # iterate over the deque's elements
... print(elem.upper())
G
H
I | trusted_official_docs | CPython Docs | .. doctest::
>>> from collections import deque
>>> d = deque('ghi') # make a new deque with three items
>>> for elem in d: # iterate over the deque's elements
... print(elem.upper())
G
H
I | .. doctest::
>>> from collections import deque
>>> d = deque('ghi') # make a new deque with three items
>>> for elem in d: # iterate over the deque's elements
... print(elem.upper())
G
H
I | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fe8caa91-a116-43b7-b8c0-08090d5ebd62 | CPython Docs | file://datasets/cpython/Doc/library/collections.rst | unknown | 0f4e51ec-13d3-4fa3-b76a-63704d522acd | 12,100 | supabase-export-v2 | d2fc5ffbad40f279 | c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping >>> c = Counter(cats=4, dogs=8) # a new counter from keyword args
Counter objects have a dictionary interface except that they return a zero
count for missing items instead of raising a :exc:`KeyError`: | trusted_official_docs | CPython Docs | c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping >>> c = Counter(cats=4, dogs=8) # a new counter from keyword args
Counter objects have a dictionary interface except that they return a zero
count for missing items instead of raising a :exc:`KeyError`: | c = Counter({'red': 4, 'blue': 2}) # a new counter from a mapping >>> c = Counter(cats=4, dogs=8) # a new counter from keyword args
Counter objects have a dictionary interface except that they return a zero
count for missing items instead of raising a :exc:`KeyError`: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
000d4764-dac4-466a-b6c2-65c201907f98 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,398 | supabase-export-v2 | 2e7869aca394ebe1 | note:: On Unix systems, when *echo_char* is set, the terminal will be configured to operate in :manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`. Common terminal control characters are supported:
* :kbd:`Ctrl+A` - Move cursor to beginning of line
* :kbd:`Ctrl+E` - Move cursor to end of line
* ... | trusted_official_docs | CPython Docs | note:: On Unix systems, when *echo_char* is set, the terminal will be configured to operate in :manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`. Common terminal control characters are supported:
* :kbd:`Ctrl+A` - Move cursor to beginning of line
* :kbd:`Ctrl+E` - Move cursor to end of line
* ... | note:: On Unix systems, when *echo_char* is set, the terminal will be configured to operate in :manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`. Common terminal control characters are supported:
* :kbd:`Ctrl+A` - Move cursor to beginning of line
* :kbd:`Ctrl+E` - Move cursor to end of line
* ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
101c2499-05d1-4153-bdad-45328defeef9 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,397 | supabase-export-v2 | 4d26760e9c2ff4fe | If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself.
.. note::
On Unix systems, when *echo_char* is set, the terminal will be
configured to operate in
:manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`. Common te... | trusted_official_docs | CPython Docs | If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself.
.. note::
On Unix systems, when *echo_char* is set, the terminal will be
configured to operate in
:manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`. Common te... | If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself.
.. note::
On Unix systems, when *echo_char* is set, the terminal will be
configured to operate in
:manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`. Common te... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3f02dd78-1b5b-41e1-adc5-36eb00f54373 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,399 | supabase-export-v2 | b92e43e51ebba62c | Kill (delete) entire line * :kbd:`Ctrl+W` - Erase previous word * :kbd:`Ctrl+V` - Insert next character literally (quote) * :kbd:`Backspace`/:kbd:`DEL` - Delete character before cursor
These shortcuts work by reading the terminal's configured control
character mappings from termios settings. | trusted_official_docs | CPython Docs | Kill (delete) entire line * :kbd:`Ctrl+W` - Erase previous word * :kbd:`Ctrl+V` - Insert next character literally (quote) * :kbd:`Backspace`/:kbd:`DEL` - Delete character before cursor
These shortcuts work by reading the terminal's configured control
character mappings from termios settings. | Kill (delete) entire line * :kbd:`Ctrl+W` - Erase previous word * :kbd:`Ctrl+V` - Insert next character literally (quote) * :kbd:`Backspace`/:kbd:`DEL` - Delete character before cursor
These shortcuts work by reading the terminal's configured control
character mappings from termios settings. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
518710ef-f54f-4765-aac6-697c778f1750 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,406 | supabase-export-v2 | dc0a6a87f30824ef | Return the "login name" of the user.
This function checks the environment variables :envvar:`LOGNAME`,
:envvar:`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and
returns the value of the first one which is set to a non-empty string. If
none are set, the login name from the password database is returned o... | trusted_official_docs | CPython Docs | Return the "login name" of the user.
This function checks the environment variables :envvar:`LOGNAME`,
:envvar:`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and
returns the value of the first one which is set to a non-empty string. If
none are set, the login name from the password database is returned o... | Return the "login name" of the user.
This function checks the environment variables :envvar:`LOGNAME`,
:envvar:`USER`, :envvar:`!LNAME` and :envvar:`USERNAME`, in order, and
returns the value of the first one which is set to a non-empty string. If
none are set, the login name from the password database is returned o... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6f2112a9-c091-45af-bdff-1d6f1b05aba7 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,396 | supabase-export-v2 | a57534a0839def7e | If echo free input is unavailable getpass() falls back to printing a warning message to *stream* and reading from ``sys.stdin`` and issuing a :exc:`GetPassWarning`.
.. note::
If you call getpass from within IDLE, the input may be done in the
terminal you launched IDLE from rather than the idle window itself. | trusted_official_docs | CPython Docs | If echo free input is unavailable getpass() falls back to printing a warning message to *stream* and reading from ``sys.stdin`` and issuing a :exc:`GetPassWarning`.
.. note::
If you call getpass from within IDLE, the input may be done in the
terminal you launched IDLE from rather than the idle window itself. | If echo free input is unavailable getpass() falls back to printing a warning message to *stream* and reading from ``sys.stdin`` and issuing a :exc:`GetPassWarning`.
.. note::
If you call getpass from within IDLE, the input may be done in the
terminal you launched IDLE from rather than the idle window itself. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a6e32e30-1186-4adc-84cb-84851b866959 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,394 | supabase-export-v2 | e98cd0db14dc0d33 | replace error handler if needed. *stream* defaults to the controlling terminal (:file:`/dev/tty`) or if that is unavailable to ``sys.stderr`` (this argument is ignored on Windows).
The *echo_char* argument controls how user input is displayed while typing. If *echo_char* is ``None`` (default), input remains hidden. Oth... | trusted_official_docs | CPython Docs | replace error handler if needed. *stream* defaults to the controlling terminal (:file:`/dev/tty`) or if that is unavailable to ``sys.stderr`` (this argument is ignored on Windows).
The *echo_char* argument controls how user input is displayed while typing. If *echo_char* is ``None`` (default), input remains hidden. Oth... | replace error handler if needed. *stream* defaults to the controlling terminal (:file:`/dev/tty`) or if that is unavailable to ``sys.stderr`` (this argument is ignored on Windows).
The *echo_char* argument controls how user input is displayed while typing. If *echo_char* is ``None`` (default), input remains hidden. Oth... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b8261a03-51bb-433e-b3ef-d059f29fcabc | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,393 | supabase-export-v2 | cca0e5de28a26a8c | .. function:: getpass(prompt='Password: ', stream=None, *, echo_char=None)
Prompt the user for a password without echoing. The user is prompted using
the string *prompt*, which defaults to ``'Password: '``. On Unix, the
prompt is written to the file-like object *stream* using the replace error
handler if needed. *st... | trusted_official_docs | CPython Docs | .. function:: getpass(prompt='Password: ', stream=None, *, echo_char=None)
Prompt the user for a password without echoing. The user is prompted using
the string *prompt*, which defaults to ``'Password: '``. On Unix, the
prompt is written to the file-like object *stream* using the replace error
handler if needed. *st... | .. function:: getpass(prompt='Password: ', stream=None, *, echo_char=None)
Prompt the user for a password without echoing. The user is prompted using
the string *prompt*, which defaults to ``'Password: '``. On Unix, the
prompt is written to the file-like object *stream* using the replace error
handler if needed. *st... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cb723643-20c3-4142-b960-600c6e0bc4a9 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,407 | supabase-export-v2 | 67fa95b64df29955 | If none are set, the login name from the password database is returned on systems which support the :mod:`pwd` module, otherwise, an :exc:`OSError` is raised.
In general, this function should be preferred over :func:`os.getlogin`. | trusted_official_docs | CPython Docs | If none are set, the login name from the password database is returned on systems which support the :mod:`pwd` module, otherwise, an :exc:`OSError` is raised.
In general, this function should be preferred over :func:`os.getlogin`. | If none are set, the login name from the password database is returned on systems which support the :mod:`pwd` module, otherwise, an :exc:`OSError` is raised.
In general, this function should be preferred over :func:`os.getlogin`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d8ac3d68-8fa4-4503-8ee2-3ee4e4ba1c80 | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,395 | supabase-export-v2 | 92f41f3638238b14 | be a single printable ASCII character and each typed character is replaced by it. For example, ``echo_char='*'`` will display asterisks instead of the actual input.
If echo free input is unavailable getpass() falls back to printing
a warning message to *stream* and reading from ``sys.stdin`` and
issuing a :exc:`GetPa... | trusted_official_docs | CPython Docs | be a single printable ASCII character and each typed character is replaced by it. For example, ``echo_char='*'`` will display asterisks instead of the actual input.
If echo free input is unavailable getpass() falls back to printing
a warning message to *stream* and reading from ``sys.stdin`` and
issuing a :exc:`GetPa... | be a single printable ASCII character and each typed character is replaced by it. For example, ``echo_char='*'`` will display asterisks instead of the actual input.
If echo free input is unavailable getpass() falls back to printing
a warning message to *stream* and reading from ``sys.stdin`` and
issuing a :exc:`GetPa... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ee972d7d-1d93-42ef-a5d3-654acb7ae87f | CPython Docs | file://datasets/cpython/Doc/library/getpass.rst | unknown | eabaa7c1-17c1-48d5-988f-f3630d325788 | 12,401 | supabase-export-v2 | 3521f36d55cbd1d1 | .. versionchanged:: 3.14 Added the *echo_char* parameter for keyboard feedback.
.. versionchanged:: 3.15
When using non-empty *echo_char* on Unix, keyboard shortcuts (including
cursor movement and line editing) are now properly handled using the
terminal's control character configuration. | trusted_official_docs | CPython Docs | .. versionchanged:: 3.14 Added the *echo_char* parameter for keyboard feedback.
.. versionchanged:: 3.15
When using non-empty *echo_char* on Unix, keyboard shortcuts (including
cursor movement and line editing) are now properly handled using the
terminal's control character configuration. | .. versionchanged:: 3.14 Added the *echo_char* parameter for keyboard feedback.
.. versionchanged:: 3.15
When using non-empty *echo_char* on Unix, keyboard shortcuts (including
cursor movement and line editing) are now properly handled using the
terminal's control character configuration. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2542f497-89b3-4650-97f4-a2e98e391563 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,447 | supabase-export-v2 | 66f0a77b5f89b787 | files.joinpath('subdir', 'subsuddir', 'file.txt') files.joinpath('subdir/subsuddir/file.txt')
Note that some :class:`!Traversable` implementations
might not be updated to the latest version of the protocol. For compatibility with such implementations, provide a single argument
without path separators to each call to ... | trusted_official_docs | CPython Docs | files.joinpath('subdir', 'subsuddir', 'file.txt') files.joinpath('subdir/subsuddir/file.txt')
Note that some :class:`!Traversable` implementations
might not be updated to the latest version of the protocol. For compatibility with such implementations, provide a single argument
without path separators to each call to ... | files.joinpath('subdir', 'subsuddir', 'file.txt') files.joinpath('subdir/subsuddir/file.txt')
Note that some :class:`!Traversable` implementations
might not be updated to the latest version of the protocol. For compatibility with such implementations, provide a single argument
without path separators to each call to ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3c1ec4ba-48ce-4d6b-9184-602e0526070d | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,417 | supabase-export-v2 | d09955fd9d431261 | is also why instances of this class are expected to directly correlate to a specific package (instead of potentially representing multiple packages or a module).
Loaders that wish to support resource reading are expected to
provide a method called ``get_resource_reader(fullname)`` which
returns an object implementing... | trusted_official_docs | CPython Docs | is also why instances of this class are expected to directly correlate to a specific package (instead of potentially representing multiple packages or a module).
Loaders that wish to support resource reading are expected to
provide a method called ``get_resource_reader(fullname)`` which
returns an object implementing... | is also why instances of this class are expected to directly correlate to a specific package (instead of potentially representing multiple packages or a module).
Loaders that wish to support resource reading are expected to
provide a method called ``get_resource_reader(fullname)`` which
returns an object implementing... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4733fe33-6ae8-4c98-9870-23467c19b441 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,418 | supabase-export-v2 | 45883f856f9342c6 | not a package, this method should return :const:`None`. An object compatible with this ABC should only be returned when the specified module is a package.
.. deprecated:: 3.12
Use :class:`importlib.resources.abc.TraversableResources` instead. | trusted_official_docs | CPython Docs | not a package, this method should return :const:`None`. An object compatible with this ABC should only be returned when the specified module is a package.
.. deprecated:: 3.12
Use :class:`importlib.resources.abc.TraversableResources` instead. | not a package, this method should return :const:`None`. An object compatible with this ABC should only be returned when the specified module is a package.
.. deprecated:: 3.12
Use :class:`importlib.resources.abc.TraversableResources` instead. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4edec1dd-7820-4859-86f7-4d177c418273 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,416 | supabase-export-v2 | 2dc734ee37075b00 | so that it does not matter if the package and its data file(s) are stored e.g. in a zip file versus on the file system.
For any of methods of this class, a *resource* argument is
expected to be a :term:`path-like object` which represents
conceptually just a file name. This means that no subdirectory
paths should be ... | trusted_official_docs | CPython Docs | so that it does not matter if the package and its data file(s) are stored e.g. in a zip file versus on the file system.
For any of methods of this class, a *resource* argument is
expected to be a :term:`path-like object` which represents
conceptually just a file name. This means that no subdirectory
paths should be ... | so that it does not matter if the package and its data file(s) are stored e.g. in a zip file versus on the file system.
For any of methods of this class, a *resource* argument is
expected to be a :term:`path-like object` which represents
conceptually just a file name. This means that no subdirectory
paths should be ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
78da6ad8-5b1c-41c8-909c-2ce6a0284999 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,462 | supabase-export-v2 | f3dfd2adf7e14a95 | capable of serving the :meth:`importlib.resources.files` interface. Subclasses :class:`ResourceReader` and provides concrete implementations of the :class:`!ResourceReader`'s abstract methods. Therefore, any loader supplying :class:`!TraversableResources` also supplies :class:`!ResourceReader`.
Loaders that wish to sup... | trusted_official_docs | CPython Docs | capable of serving the :meth:`importlib.resources.files` interface. Subclasses :class:`ResourceReader` and provides concrete implementations of the :class:`!ResourceReader`'s abstract methods. Therefore, any loader supplying :class:`!TraversableResources` also supplies :class:`!ResourceReader`.
Loaders that wish to sup... | capable of serving the :meth:`importlib.resources.files` interface. Subclasses :class:`ResourceReader` and provides concrete implementations of the :class:`!ResourceReader`'s abstract methods. Therefore, any loader supplying :class:`!TraversableResources` also supplies :class:`!ResourceReader`.
Loaders that wish to sup... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8146065b-cd06-44e3-8cf7-d6c036df1434 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,429 | supabase-export-v2 | fe2767ad734c785a | .. method:: contents() :abstractmethod:
Returns an :term:`iterable` of strings over the contents of
the package. Do note that it is not required that all names
returned by the iterator be actual resources, e.g. it is
acceptable to return names for which :meth:`is_resource` would
be false. | trusted_official_docs | CPython Docs | .. method:: contents() :abstractmethod:
Returns an :term:`iterable` of strings over the contents of
the package. Do note that it is not required that all names
returned by the iterator be actual resources, e.g. it is
acceptable to return names for which :meth:`is_resource` would
be false. | .. method:: contents() :abstractmethod:
Returns an :term:`iterable` of strings over the contents of
the package. Do note that it is not required that all names
returned by the iterator be actual resources, e.g. it is
acceptable to return names for which :meth:`is_resource` would
be false. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
843bae91-4331-4806-8b6c-bc898aa10206 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,430 | supabase-export-v2 | 1ccb8828f253460d | not required that all names returned by the iterator be actual resources, e.g. it is acceptable to return names for which :meth:`is_resource` would be false.
Allowing non-resource names to be returned is to allow for
situations where how a package and its resources are stored
are known a priori and the non-resource n... | trusted_official_docs | CPython Docs | not required that all names returned by the iterator be actual resources, e.g. it is acceptable to return names for which :meth:`is_resource` would be false.
Allowing non-resource names to be returned is to allow for
situations where how a package and its resources are stored
are known a priori and the non-resource n... | not required that all names returned by the iterator be actual resources, e.g. it is acceptable to return names for which :meth:`is_resource` would be false.
Allowing non-resource names to be returned is to allow for
situations where how a package and its resources are stored
are known a priori and the non-resource n... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a0f3d800-03bc-42d2-b6d6-15fa7c18dc4b | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,461 | supabase-export-v2 | 8b69a0b4b5bb7cf7 | .. class:: TraversableResources
An abstract base class for resource readers capable of serving
the :meth:`importlib.resources.files` interface. Subclasses
:class:`ResourceReader` and provides
concrete implementations of the :class:`!ResourceReader`'s
abstract methods. Therefore, any loader supplying
:class:`!Trave... | trusted_official_docs | CPython Docs | .. class:: TraversableResources
An abstract base class for resource readers capable of serving
the :meth:`importlib.resources.files` interface. Subclasses
:class:`ResourceReader` and provides
concrete implementations of the :class:`!ResourceReader`'s
abstract methods. Therefore, any loader supplying
:class:`!Trave... | .. class:: TraversableResources
An abstract base class for resource readers capable of serving
the :meth:`importlib.resources.files` interface. Subclasses
:class:`ResourceReader` and provides
concrete implementations of the :class:`!ResourceReader`'s
abstract methods. Therefore, any loader supplying
:class:`!Trave... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b75ff0a5-f5a7-4903-a7c2-311db70d08a4 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,455 | supabase-export-v2 | 9fbd905b380d002c | *mode* may be 'r' or 'rb' to open as text or binary. Return a handle suitable for reading (same as :attr:`pathlib.Path.open`).
When opening as text, accepts encoding parameters such as those
accepted by :class:`io.TextIOWrapper`. | trusted_official_docs | CPython Docs | *mode* may be 'r' or 'rb' to open as text or binary. Return a handle suitable for reading (same as :attr:`pathlib.Path.open`).
When opening as text, accepts encoding parameters such as those
accepted by :class:`io.TextIOWrapper`. | *mode* may be 'r' or 'rb' to open as text or binary. Return a handle suitable for reading (same as :attr:`pathlib.Path.open`).
When opening as text, accepts encoding parameters such as those
accepted by :class:`io.TextIOWrapper`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cc4a3b8f-aa65-46ff-9010-90e3e3ee2df9 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,445 | supabase-export-v2 | 154148e4aaad5eb0 | Traverse directories according to *pathsegments* and return the result as :class:`!Traversable`.
Each *pathsegments* argument may contain multiple names separated by
forward slashes (``/``, ``posixpath.sep`` ). For example, the following are equivalent:: | trusted_official_docs | CPython Docs | Traverse directories according to *pathsegments* and return the result as :class:`!Traversable`.
Each *pathsegments* argument may contain multiple names separated by
forward slashes (``/``, ``posixpath.sep`` ). For example, the following are equivalent:: | Traverse directories according to *pathsegments* and return the result as :class:`!Traversable`.
Each *pathsegments* argument may contain multiple names separated by
forward slashes (``/``, ``posixpath.sep`` ). For example, the following are equivalent:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
db11a8a8-4e17-481d-aa7a-5d213c695246 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,415 | supabase-export-v2 | 22ed038f5de1efc4 | An :term:`abstract base class` to provide the ability to read *resources*.
From the perspective of this ABC, a *resource* is a binary
artifact that is shipped within a package. Typically this is
something like a data file that lives next to the ``__init__.py``
file of the package. The purpose of this class is to hel... | trusted_official_docs | CPython Docs | An :term:`abstract base class` to provide the ability to read *resources*.
From the perspective of this ABC, a *resource* is a binary
artifact that is shipped within a package. Typically this is
something like a data file that lives next to the ``__init__.py``
file of the package. The purpose of this class is to hel... | An :term:`abstract base class` to provide the ability to read *resources*.
From the perspective of this ABC, a *resource* is a binary
artifact that is shipped within a package. Typically this is
something like a data file that lives next to the ``__init__.py``
file of the package. The purpose of this class is to hel... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ed90bb64-f10d-4f17-ad3a-e9c0c0334183 | CPython Docs | file://datasets/cpython/Doc/library/importlib.resources.abc.rst | unknown | 2c8d422c-14f5-4216-b17f-40f4288db6b5 | 12,431 | supabase-export-v2 | e3d3282b5e432fa1 | so that when it is known that the package and resources are stored on the file system then those subdirectory names can be used directly.
The abstract method returns an iterable of no items. | trusted_official_docs | CPython Docs | so that when it is known that the package and resources are stored on the file system then those subdirectory names can be used directly.
The abstract method returns an iterable of no items. | so that when it is known that the package and resources are stored on the file system then those subdirectory names can be used directly.
The abstract method returns an iterable of no items. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0af953d2-7064-46a7-9b55-e80a7edb17be | CPython Docs | file://datasets/cpython/Doc/library/binary.rst | unknown | 1f1d4d43-a37c-45a8-90d0-79f85daf00a0 | 12,475 | supabase-export-v2 | 2767b6fe1d6ef879 | ******************** Binary Data Services ********************
The modules described in this chapter provide some basic services operations
for manipulation of binary data. Other operations on binary data, specifically
in relation to file formats and network protocols, are described in the
relevant sections. | trusted_official_docs | CPython Docs | ******************** Binary Data Services ********************
The modules described in this chapter provide some basic services operations
for manipulation of binary data. Other operations on binary data, specifically
in relation to file formats and network protocols, are described in the
relevant sections. | ******************** Binary Data Services ********************
The modules described in this chapter provide some basic services operations
for manipulation of binary data. Other operations on binary data, specifically
in relation to file formats and network protocols, are described in the
relevant sections. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7417089f-c721-45c9-9284-8351d803ecca | CPython Docs | file://datasets/cpython/Doc/library/binary.rst | unknown | 1f1d4d43-a37c-45a8-90d0-79f85daf00a0 | 12,476 | supabase-export-v2 | 0c719301cfe833c5 | for manipulation of binary data. Other operations on binary data, specifically in relation to file formats and network protocols, are described in the relevant sections.
Some libraries described under :ref:`textservices` also work with either
ASCII-compatible binary formats (for example, :mod:`re`) or all binary data
(... | trusted_official_docs | CPython Docs | for manipulation of binary data. Other operations on binary data, specifically in relation to file formats and network protocols, are described in the relevant sections.
Some libraries described under :ref:`textservices` also work with either
ASCII-compatible binary formats (for example, :mod:`re`) or all binary data
(... | for manipulation of binary data. Other operations on binary data, specifically in relation to file formats and network protocols, are described in the relevant sections.
Some libraries described under :ref:`textservices` also work with either
ASCII-compatible binary formats (for example, :mod:`re`) or all binary data
(... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
84afa65a-1fd9-496d-a2a6-0dfa1d7dc73c | CPython Docs | file://datasets/cpython/Doc/library/binary.rst | unknown | 1f1d4d43-a37c-45a8-90d0-79f85daf00a0 | 12,477 | supabase-export-v2 | 8bee13f89b3e5867 | Some libraries described under :ref:`textservices` also work with either ASCII-compatible binary formats (for example, :mod:`re`) or all binary data (for example, :mod:`difflib`).
In addition, see the documentation for Python's built-in binary data types in
:ref:`binaryseq`. | trusted_official_docs | CPython Docs | Some libraries described under :ref:`textservices` also work with either ASCII-compatible binary formats (for example, :mod:`re`) or all binary data (for example, :mod:`difflib`).
In addition, see the documentation for Python's built-in binary data types in
:ref:`binaryseq`. | Some libraries described under :ref:`textservices` also work with either ASCII-compatible binary formats (for example, :mod:`re`) or all binary data (for example, :mod:`difflib`).
In addition, see the documentation for Python's built-in binary data types in
:ref:`binaryseq`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ac7590d1-5dd5-4a01-b1d0-e143223ea0ac | CPython Docs | file://datasets/cpython/Doc/library/nis.rst | unknown | 3c756303-447b-4e28-9bde-fb0ed432684d | 12,483 | supabase-export-v2 | bc2eac2af7a5efcc | part of the Python standard library. It was :ref:`removed in Python 3.13 <whatsnew313-pep594>` after being deprecated in Python 3.11. The removal was decided in :pep:`594`.
The last version of Python that provided the :mod:`!nis` module was
`Python 3.12 <https://docs.python.org/3.12/library/nis.html>`_. | trusted_official_docs | CPython Docs | part of the Python standard library. It was :ref:`removed in Python 3.13 <whatsnew313-pep594>` after being deprecated in Python 3.11. The removal was decided in :pep:`594`.
The last version of Python that provided the :mod:`!nis` module was
`Python 3.12 <https://docs.python.org/3.12/library/nis.html>`_. | part of the Python standard library. It was :ref:`removed in Python 3.13 <whatsnew313-pep594>` after being deprecated in Python 3.11. The removal was decided in :pep:`594`.
The last version of Python that provided the :mod:`!nis` module was
`Python 3.12 <https://docs.python.org/3.12/library/nis.html>`_. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
01186093-7423-4feb-8a4a-109e0d144380 | CPython Docs | file://datasets/cpython/Doc/library/zipfile.rst | unknown | c4ec3663-7be8-44a9-94ce-5bf7f8c7b8f5 | 12,580 | supabase-export-v2 | 9829972d7d6da759 | .. method:: ZipFile.extract(member, path=None, pwd=None)
Extract a member from the archive to the current working directory; *member*
must be its full name or a :class:`ZipInfo` object. Its file information is
extracted as accurately as possible. *path* specifies a different directory
to extract to. *member* can be ... | trusted_official_docs | CPython Docs | .. method:: ZipFile.extract(member, path=None, pwd=None)
Extract a member from the archive to the current working directory; *member*
must be its full name or a :class:`ZipInfo` object. Its file information is
extracted as accurately as possible. *path* specifies a different directory
to extract to. *member* can be ... | .. method:: ZipFile.extract(member, path=None, pwd=None)
Extract a member from the archive to the current working directory; *member*
must be its full name or a :class:`ZipInfo` object. Its file information is
extracted as accurately as possible. *path* specifies a different directory
to extract to. *member* can be ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
013eff98-d11a-4d36-b973-44d7f26944b2 | CPython Docs | file://datasets/cpython/Doc/library/zipfile.rst | unknown | c4ec3663-7be8-44a9-94ce-5bf7f8c7b8f5 | 12,584 | supabase-export-v2 | eacda41da985d511 | member filename will be removed, e.g.: ``../../foo../../ba..r`` becomes ``foo../ba..r``. On Windows illegal characters (``:``, ``<``, ``>``, ``|``, ``"``, ``?``, and ``*``) replaced by underscore (``_``).
.. versionchanged:: 3.6
Calling :meth:`extract` on a closed ZipFile will raise a
:exc:`ValueError`. Previously, a... | trusted_official_docs | CPython Docs | member filename will be removed, e.g.: ``../../foo../../ba..r`` becomes ``foo../ba..r``. On Windows illegal characters (``:``, ``<``, ``>``, ``|``, ``"``, ``?``, and ``*``) replaced by underscore (``_``).
.. versionchanged:: 3.6
Calling :meth:`extract` on a closed ZipFile will raise a
:exc:`ValueError`. Previously, a... | member filename will be removed, e.g.: ``../../foo../../ba..r`` becomes ``foo../ba..r``. On Windows illegal characters (``:``, ``<``, ``>``, ``|``, ``"``, ``?``, and ``*``) replaced by underscore (``_``).
.. versionchanged:: 3.6
Calling :meth:`extract` on a closed ZipFile will raise a
:exc:`ValueError`. Previously, a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
040c4913-ec0d-41ca-b816-be322a58daad | CPython Docs | file://datasets/cpython/Doc/library/zipfile.rst | unknown | c4ec3663-7be8-44a9-94ce-5bf7f8c7b8f5 | 12,631 | supabase-export-v2 | 45efecbccf867254 | .. attribute:: ZipFile.comment
The comment associated with the ZIP file as a :class:`bytes` object. If assigning a comment to a
:class:`ZipFile` instance created with mode ``'w'``, ``'x'`` or ``'a'``,
it should be no longer than 65535 bytes. Comments longer than this will be
truncated. | trusted_official_docs | CPython Docs | .. attribute:: ZipFile.comment
The comment associated with the ZIP file as a :class:`bytes` object. If assigning a comment to a
:class:`ZipFile` instance created with mode ``'w'``, ``'x'`` or ``'a'``,
it should be no longer than 65535 bytes. Comments longer than this will be
truncated. | .. attribute:: ZipFile.comment
The comment associated with the ZIP file as a :class:`bytes` object. If assigning a comment to a
:class:`ZipFile` instance created with mode ``'w'``, ``'x'`` or ``'a'``,
it should be no longer than 65535 bytes. Comments longer than this will be
truncated. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
08f0a761-5137-4758-a3a5-7059cc434c7f | CPython Docs | file://datasets/cpython/Doc/library/zipfile.rst | unknown | c4ec3663-7be8-44a9-94ce-5bf7f8c7b8f5 | 12,688 | supabase-export-v2 | f2f11456093fbcf2 | added under the package name as a file path, and if any subdirectories are package directories, all of these are added recursively in sorted order.
*basename* is intended for internal use only. | trusted_official_docs | CPython Docs | added under the package name as a file path, and if any subdirectories are package directories, all of these are added recursively in sorted order.
*basename* is intended for internal use only. | added under the package name as a file path, and if any subdirectories are package directories, all of these are added recursively in sorted order.
*basename* is intended for internal use only. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0954bdbf-a0a6-4360-88bb-4093eb1b6b68 | CPython Docs | file://datasets/cpython/Doc/library/zipfile.rst | unknown | c4ec3663-7be8-44a9-94ce-5bf7f8c7b8f5 | 12,526 | supabase-export-v2 | e141e057ad78123d | .. note::
In APPNOTE 6.3.7, the method ID ``20`` was assigned to Zstandard
compression. This was changed in APPNOTE 6.3.8 to method ID ``93`` to
avoid conflicts, with method ID ``20`` being deprecated. For
compatibility, the :mod:`!zipfile` module reads both method IDs but will
only write data with method ID ``93``... | trusted_official_docs | CPython Docs | .. note::
In APPNOTE 6.3.7, the method ID ``20`` was assigned to Zstandard
compression. This was changed in APPNOTE 6.3.8 to method ID ``93`` to
avoid conflicts, with method ID ``20`` being deprecated. For
compatibility, the :mod:`!zipfile` module reads both method IDs but will
only write data with method ID ``93``... | .. note::
In APPNOTE 6.3.7, the method ID ``20`` was assigned to Zstandard
compression. This was changed in APPNOTE 6.3.8 to method ID ``93`` to
avoid conflicts, with method ID ``20`` being deprecated. For
compatibility, the :mod:`!zipfile` module reads both method IDs but will
only write data with method ID ``93``... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0ad1b651-5611-4a38-bd13-e0945e26f338 | CPython Docs | file://datasets/cpython/Doc/library/zipfile.rst | unknown | c4ec3663-7be8-44a9-94ce-5bf7f8c7b8f5 | 12,780 | supabase-export-v2 | 7e93b383b0d2d5c5 | File system limitations ~~~~~~~~~~~~~~~~~~~~~~~
Exceeding limitations on different file systems can cause decompression failed. Such as allowable characters in the directory entries, length of the file name,
length of the pathname, size of a single file, and number of files, etc. | trusted_official_docs | CPython Docs | File system limitations ~~~~~~~~~~~~~~~~~~~~~~~
Exceeding limitations on different file systems can cause decompression failed. Such as allowable characters in the directory entries, length of the file name,
length of the pathname, size of a single file, and number of files, etc. | File system limitations ~~~~~~~~~~~~~~~~~~~~~~~
Exceeding limitations on different file systems can cause decompression failed. Such as allowable characters in the directory entries, length of the file name,
length of the pathname, size of a single file, and number of files, etc. | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.