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
430b32a3-8dfc-486a-88cf-c6cb2b590961
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,296
supabase-export-v2
7b404b21b8d470d1
.. note:: Unlike f-strings, where conversions are applied automatically, the expected behavior with t-strings is that code that *processes* the :class:`!Template` will decide how to interpret and whether to apply the :attr:`!conversion`. For convenience, the :func:`convert` function can be used to mimic f-string co...
trusted_official_docs
CPython Docs
.. note:: Unlike f-strings, where conversions are applied automatically, the expected behavior with t-strings is that code that *processes* the :class:`!Template` will decide how to interpret and whether to apply the :attr:`!conversion`. For convenience, the :func:`convert` function can be used to mimic f-string co...
.. note:: Unlike f-strings, where conversions are applied automatically, the expected behavior with t-strings is that code that *processes* the :class:`!Template` will decide how to interpret and whether to apply the :attr:`!conversion`. For convenience, the :func:`convert` function can be used to mimic f-string co...
python, official-docs, cpython, P0
Local_Trusted_Corpus
435af2e4-0b80-4617-bea1-21cd2aafe396
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,259
supabase-export-v2
b2cbc956508c6bb0
>>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.values ('Camembert',) The ``values`` tuple always has the same length as the ``interpolations`` tuple. It is always equivalent to ``tuple(i.value for i in template.interpolations)``.
trusted_official_docs
CPython Docs
>>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.values ('Camembert',) The ``values`` tuple always has the same length as the ``interpolations`` tuple. It is always equivalent to ``tuple(i.value for i in template.interpolations)``.
>>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.values ('Camembert',) The ``values`` tuple always has the same length as the ``interpolations`` tuple. It is always equivalent to ``tuple(i.value for i in template.interpolations)``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
576a8bf7-4d86-4809-b589-d703da642468
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,263
supabase-export-v2
f543dd2adf23acc2
While literal syntax is the most common way to create a :class:`!Template`, it is also possible to create them directly using the constructor: >>> from string.templatelib import Interpolation, Template >>> cheese = 'Camembert' >>> template = Template( ... 'Ah! We do have ', Interpolation(cheese, 'cheese'), '.' ... ...
trusted_official_docs
CPython Docs
While literal syntax is the most common way to create a :class:`!Template`, it is also possible to create them directly using the constructor: >>> from string.templatelib import Interpolation, Template >>> cheese = 'Camembert' >>> template = Template( ... 'Ah! We do have ', Interpolation(cheese, 'cheese'), '.' ... ...
While literal syntax is the most common way to create a :class:`!Template`, it is also possible to create them directly using the constructor: >>> from string.templatelib import Interpolation, Template >>> cheese = 'Camembert' >>> template = Template( ... 'Ah! We do have ', Interpolation(cheese, 'cheese'), '.' ... ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6293384d-cd41-4a82-8a65-43714b36065d
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,281
supabase-export-v2
0c239bd76205197e
The :class:`!Interpolation` type represents an expression inside a template string. It is immutable, meaning that attributes of an interpolation cannot be reassigned. Interpolations support pattern matching, allowing you to match against their attributes with the :ref:`match statement <match>`:
trusted_official_docs
CPython Docs
The :class:`!Interpolation` type represents an expression inside a template string. It is immutable, meaning that attributes of an interpolation cannot be reassigned. Interpolations support pattern matching, allowing you to match against their attributes with the :ref:`match statement <match>`:
The :class:`!Interpolation` type represents an expression inside a template string. It is immutable, meaning that attributes of an interpolation cannot be reassigned. Interpolations support pattern matching, allowing you to match against their attributes with the :ref:`match statement <match>`:
python, official-docs, cpython, P0
Local_Trusted_Corpus
63a7b793-6081-4391-b8d4-ac8b84007326
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,306
supabase-export-v2
db427f9d02469e8b
Create a new :class:`!Interpolation` object from component parts. :param value: The evaluated, in-scope result of the interpolation. :param expression: The text of a valid Python expression, or an empty string. :param conversion: The :ref:`conversion <formatstrings>` to be used, one of ``None``, ``'a'``, ``'r'``, or ...
trusted_official_docs
CPython Docs
Create a new :class:`!Interpolation` object from component parts. :param value: The evaluated, in-scope result of the interpolation. :param expression: The text of a valid Python expression, or an empty string. :param conversion: The :ref:`conversion <formatstrings>` to be used, one of ``None``, ``'a'``, ``'r'``, or ...
Create a new :class:`!Interpolation` object from component parts. :param value: The evaluated, in-scope result of the interpolation. :param expression: The text of a valid Python expression, or an empty string. :param conversion: The :ref:`conversion <formatstrings>` to be used, one of ``None``, ``'a'``, ``'r'``, or ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
68b1f8a2-feb7-4f68-bff9-17861cc0031b
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,311
supabase-export-v2
cd69bca2ee10e66b
Three conversion flags are currently supported: * ``'s'`` which calls :func:`str` on the value (like ``!s``), * ``'r'`` which calls :func:`repr` (like ``!r``), and * ``'a'`` which calls :func:`ascii` (like ``!a``).
trusted_official_docs
CPython Docs
Three conversion flags are currently supported: * ``'s'`` which calls :func:`str` on the value (like ``!s``), * ``'r'`` which calls :func:`repr` (like ``!r``), and * ``'a'`` which calls :func:`ascii` (like ``!a``).
Three conversion flags are currently supported: * ``'s'`` which calls :func:`str` on the value (like ``!s``), * ``'r'`` which calls :func:`repr` (like ``!r``), and * ``'a'`` which calls :func:`ascii` (like ``!a``).
python, official-docs, cpython, P0
Local_Trusted_Corpus
6d2e2789-41de-4c5e-b12b-68a0b4a4ff4e
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,266
supabase-export-v2
8d8c86b1ae25eb0c
>>> from string.templatelib import Template >>> template = Template('Ah! We do have ', 'Camembert', '.') >>> template.strings ('Ah! We do have Camembert.',) If multiple interpolations are passed consecutively, they will be treated as separate interpolations and an empty string will be inserted between them. For exampl...
trusted_official_docs
CPython Docs
>>> from string.templatelib import Template >>> template = Template('Ah! We do have ', 'Camembert', '.') >>> template.strings ('Ah! We do have Camembert.',) If multiple interpolations are passed consecutively, they will be treated as separate interpolations and an empty string will be inserted between them. For exampl...
>>> from string.templatelib import Template >>> template = Template('Ah! We do have ', 'Camembert', '.') >>> template.strings ('Ah! We do have Camembert.',) If multiple interpolations are passed consecutively, they will be treated as separate interpolations and an empty string will be inserted between them. For exampl...
python, official-docs, cpython, P0
Local_Trusted_Corpus
70ef580d-7fe9-4cae-9e01-ba4b841cce07
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,273
supabase-export-v2
a532f23b2f5edbd6
Empty strings are **not** included in the iteration: >>> response = 'We do have ' >>> cheese = 'Camembert' >>> list(t'Ah! {response}{cheese}.') # doctest: +NORMALIZE_WHITESPACE ['Ah! ', Interpolation('We do have ', 'response', None, ''), Interpolation('Camembert', 'cheese', None, ''), '.']
trusted_official_docs
CPython Docs
Empty strings are **not** included in the iteration: >>> response = 'We do have ' >>> cheese = 'Camembert' >>> list(t'Ah! {response}{cheese}.') # doctest: +NORMALIZE_WHITESPACE ['Ah! ', Interpolation('We do have ', 'response', None, ''), Interpolation('Camembert', 'cheese', None, ''), '.']
Empty strings are **not** included in the iteration: >>> response = 'We do have ' >>> cheese = 'Camembert' >>> list(t'Ah! {response}{cheese}.') # doctest: +NORMALIZE_WHITESPACE ['Ah! ', Interpolation('We do have ', 'response', None, ''), Interpolation('Camembert', 'cheese', None, ''), '.']
python, official-docs, cpython, P0
Local_Trusted_Corpus
731bf72f-b314-4076-8435-3e5e24d269ef
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,237
supabase-export-v2
0ae8b62ef816cdb1
string literal syntax <t-strings>`. This syntax is identical to that of :ref:`f-strings <f-strings>`, except that it uses a ``t`` prefix in place of an ``f``: >>> cheese = 'Red Leicester' >>> template = t"We're fresh out of {cheese}, sir." >>> type(template) <class 'string.templatelib.Template'>
trusted_official_docs
CPython Docs
string literal syntax <t-strings>`. This syntax is identical to that of :ref:`f-strings <f-strings>`, except that it uses a ``t`` prefix in place of an ``f``: >>> cheese = 'Red Leicester' >>> template = t"We're fresh out of {cheese}, sir." >>> type(template) <class 'string.templatelib.Template'>
string literal syntax <t-strings>`. This syntax is identical to that of :ref:`f-strings <f-strings>`, except that it uses a ``t`` prefix in place of an ``f``: >>> cheese = 'Red Leicester' >>> template = t"We're fresh out of {cheese}, sir." >>> type(template) <class 'string.templatelib.Template'>
python, official-docs, cpython, P0
Local_Trusted_Corpus
74851efd-7b6e-4fbd-b3c2-fd24db2e2eb7
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,250
supabase-export-v2
7681d8202d6f2269
The ``strings`` tuple is never empty, and always contains one more string than the ``interpolations`` and ``values`` tuples: >>> t''.strings ('',) >>> t''.values () >>> t'{'cheese'}'.strings ('', '') >>> t'{'cheese'}'.values ('cheese',)
trusted_official_docs
CPython Docs
The ``strings`` tuple is never empty, and always contains one more string than the ``interpolations`` and ``values`` tuples: >>> t''.strings ('',) >>> t''.values () >>> t'{'cheese'}'.strings ('', '') >>> t'{'cheese'}'.values ('cheese',)
The ``strings`` tuple is never empty, and always contains one more string than the ``interpolations`` and ``values`` tuples: >>> t''.strings ('',) >>> t''.values () >>> t'{'cheese'}'.strings ('', '') >>> t'{'cheese'}'.values ('cheese',)
python, official-docs, cpython, P0
Local_Trusted_Corpus
80f29a2a-de3a-415e-9351-a8944716eea8
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,276
supabase-export-v2
854bf2d2f721662c
Concatenate this template with another, returning a new :class:`!Template` instance: >>> cheese = 'Camembert' >>> list(t'Ah! ' + t'We do have {cheese}.') ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.']
trusted_official_docs
CPython Docs
Concatenate this template with another, returning a new :class:`!Template` instance: >>> cheese = 'Camembert' >>> list(t'Ah! ' + t'We do have {cheese}.') ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.']
Concatenate this template with another, returning a new :class:`!Template` instance: >>> cheese = 'Camembert' >>> list(t'Ah! ' + t'We do have {cheese}.') ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.']
python, official-docs, cpython, P0
Local_Trusted_Corpus
89aaf83f-fa52-4e62-8f11-34e58ebce8cf
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,297
supabase-export-v2
dbcfcc6dabb7b843
:class:`!Template` will decide how to interpret and whether to apply the :attr:`!conversion`. For convenience, the :func:`convert` function can be used to mimic f-string conversion semantics. .. attribute:: format_spec :type: str
trusted_official_docs
CPython Docs
:class:`!Template` will decide how to interpret and whether to apply the :attr:`!conversion`. For convenience, the :func:`convert` function can be used to mimic f-string conversion semantics. .. attribute:: format_spec :type: str
:class:`!Template` will decide how to interpret and whether to apply the :attr:`!conversion`. For convenience, the :func:`convert` function can be used to mimic f-string conversion semantics. .. attribute:: format_spec :type: str
python, official-docs, cpython, P0
Local_Trusted_Corpus
89d8060e-8c45-4307-a763-c020b7360e26
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,302
supabase-export-v2
a8d422853d1e11ef
.. note:: Unlike f-strings, where format specifications are applied automatically via the :func:`format` protocol, the expected behavior with t-strings is that code that *processes* the interpolation will decide how to interpret and whether to apply the format specification. As a result, :attr:`!format_spec` values ...
trusted_official_docs
CPython Docs
.. note:: Unlike f-strings, where format specifications are applied automatically via the :func:`format` protocol, the expected behavior with t-strings is that code that *processes* the interpolation will decide how to interpret and whether to apply the format specification. As a result, :attr:`!format_spec` values ...
.. note:: Unlike f-strings, where format specifications are applied automatically via the :func:`format` protocol, the expected behavior with t-strings is that code that *processes* the interpolation will decide how to interpret and whether to apply the format specification. As a result, :attr:`!format_spec` values ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8e5038c0-3795-4ca0-83ea-e25ba5cbf767
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,282
supabase-export-v2
d8e74d6051dbc083
Interpolations support pattern matching, allowing you to match against their attributes with the :ref:`match statement <match>`: >>> from string.templatelib import Interpolation >>> interpolation = t'{1. + 2.:.2f}'.interpolations[0] >>> interpolation Interpolation(3.0, '1. + 2.', None, '.2f') >>> match interpolatio...
trusted_official_docs
CPython Docs
Interpolations support pattern matching, allowing you to match against their attributes with the :ref:`match statement <match>`: >>> from string.templatelib import Interpolation >>> interpolation = t'{1. + 2.:.2f}'.interpolations[0] >>> interpolation Interpolation(3.0, '1. + 2.', None, '.2f') >>> match interpolatio...
Interpolations support pattern matching, allowing you to match against their attributes with the :ref:`match statement <match>`: >>> from string.templatelib import Interpolation >>> interpolation = t'{1. + 2.:.2f}'.interpolations[0] >>> interpolation Interpolation(3.0, '1. + 2.', None, '.2f') >>> match interpolatio...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9a1901da-9a98-4553-ba28-419fba9293e4
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,264
supabase-export-v2
86c72c695f6fed23
= Template( ... 'Ah! We do have ', Interpolation(cheese, 'cheese'), '.' ... ) >>> list(template) ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.'] If multiple strings are passed consecutively, they will be concatenated into a single value in the :attr:`~Template.strings` attribute. For example, ...
trusted_official_docs
CPython Docs
= Template( ... 'Ah! We do have ', Interpolation(cheese, 'cheese'), '.' ... ) >>> list(template) ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.'] If multiple strings are passed consecutively, they will be concatenated into a single value in the :attr:`~Template.strings` attribute. For example, ...
= Template( ... 'Ah! We do have ', Interpolation(cheese, 'cheese'), '.' ... ) >>> list(template) ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.'] If multiple strings are passed consecutively, they will be concatenated into a single value in the :attr:`~Template.strings` attribute. For example, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a6b8f2fc-3134-4c62-a1cc-f32632fe6d36
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,239
supabase-export-v2
03b2c58272f06d3e
Templates are stored as sequences of literal :attr:`~Template.strings` and dynamic :attr:`~Template.interpolations`. A :attr:`~Template.values` attribute holds the values of the interpolations: >>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.strings ('Ah! We do have ', '.') >>> temp...
trusted_official_docs
CPython Docs
Templates are stored as sequences of literal :attr:`~Template.strings` and dynamic :attr:`~Template.interpolations`. A :attr:`~Template.values` attribute holds the values of the interpolations: >>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.strings ('Ah! We do have ', '.') >>> temp...
Templates are stored as sequences of literal :attr:`~Template.strings` and dynamic :attr:`~Template.interpolations`. A :attr:`~Template.values` attribute holds the values of the interpolations: >>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.strings ('Ah! We do have ', '.') >>> temp...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b20028fa-d81e-433d-af8f-ad69aa29f151
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,274
supabase-export-v2
1002f2fd8e671a89
' >>> cheese = 'Camembert' >>> list(t'Ah! {response}{cheese}.') # doctest: +NORMALIZE_WHITESPACE ['Ah! ', Interpolation('We do have ', 'response', None, ''), Interpolation('Camembert', 'cheese', None, ''), '.'] .. describe:: template + other template += other
trusted_official_docs
CPython Docs
' >>> cheese = 'Camembert' >>> list(t'Ah! {response}{cheese}.') # doctest: +NORMALIZE_WHITESPACE ['Ah! ', Interpolation('We do have ', 'response', None, ''), Interpolation('Camembert', 'cheese', None, ''), '.'] .. describe:: template + other template += other
' >>> cheese = 'Camembert' >>> list(t'Ah! {response}{cheese}.') # doctest: +NORMALIZE_WHITESPACE ['Ah! ', Interpolation('We do have ', 'response', None, ''), Interpolation('Camembert', 'cheese', None, ''), '.'] .. describe:: template + other template += other
python, official-docs, cpython, P0
Local_Trusted_Corpus
bc45dd9d-7eba-409b-84c5-a3666b23b533
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,267
supabase-export-v2
acb4597b44fb101c
interpolations and an empty string will be inserted between them. For example, the following code creates a template with empty placeholders in the :attr:`~Template.strings` attribute: >>> from string.templatelib import Interpolation, Template >>> template = Template( ... Interpolation('Camembert', 'cheese'), ... In...
trusted_official_docs
CPython Docs
interpolations and an empty string will be inserted between them. For example, the following code creates a template with empty placeholders in the :attr:`~Template.strings` attribute: >>> from string.templatelib import Interpolation, Template >>> template = Template( ... Interpolation('Camembert', 'cheese'), ... In...
interpolations and an empty string will be inserted between them. For example, the following code creates a template with empty placeholders in the :attr:`~Template.strings` attribute: >>> from string.templatelib import Interpolation, Template >>> template = Template( ... Interpolation('Camembert', 'cheese'), ... In...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bc686a65-3474-42d7-a254-9dfa935cf5d2
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,249
supabase-export-v2
583808b3f4fa5af5
>>> response = 'We do have ' >>> cheese = 'Camembert' >>> template = t'Ah! {response}{cheese}.' >>> template.strings ('Ah! ', '', '.') The ``strings`` tuple is never empty, and always contains one more string than the ``interpolations`` and ``values`` tuples:
trusted_official_docs
CPython Docs
>>> response = 'We do have ' >>> cheese = 'Camembert' >>> template = t'Ah! {response}{cheese}.' >>> template.strings ('Ah! ', '', '.') The ``strings`` tuple is never empty, and always contains one more string than the ``interpolations`` and ``values`` tuples:
>>> response = 'We do have ' >>> cheese = 'Camembert' >>> template = t'Ah! {response}{cheese}.' >>> template.strings ('Ah! ', '', '.') The ``strings`` tuple is never empty, and always contains one more string than the ``interpolations`` and ``values`` tuples:
python, official-docs, cpython, P0
Local_Trusted_Corpus
c08a908d-e9c1-4d03-8c07-17ee81b25887
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,231
supabase-export-v2
c9329dfab2004712
:ref:`f-strings`, but return a :class:`Template` instance that gives access to the static and interpolated (in curly brackets) parts of a string *before* they are combined. To write a t-string, use a ``'t'`` prefix instead of an ``'f'``, like so:
trusted_official_docs
CPython Docs
:ref:`f-strings`, but return a :class:`Template` instance that gives access to the static and interpolated (in curly brackets) parts of a string *before* they are combined. To write a t-string, use a ``'t'`` prefix instead of an ``'f'``, like so:
:ref:`f-strings`, but return a :class:`Template` instance that gives access to the static and interpolated (in curly brackets) parts of a string *before* they are combined. To write a t-string, use a ``'t'`` prefix instead of an ``'f'``, like so:
python, official-docs, cpython, P0
Local_Trusted_Corpus
d18450ec-b644-44cb-bb39-c079742678bd
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,236
supabase-export-v2
db5803bfffb9b944
The :class:`!Template` class describes the contents of a template string. It is immutable, meaning that attributes of a template cannot be reassigned. The most common way to create a :class:`!Template` instance is to use the :ref:`template string literal syntax <t-strings>`. This syntax is identical to that of :ref:`f...
trusted_official_docs
CPython Docs
The :class:`!Template` class describes the contents of a template string. It is immutable, meaning that attributes of a template cannot be reassigned. The most common way to create a :class:`!Template` instance is to use the :ref:`template string literal syntax <t-strings>`. This syntax is identical to that of :ref:`f...
The :class:`!Template` class describes the contents of a template string. It is immutable, meaning that attributes of a template cannot be reassigned. The most common way to create a :class:`!Template` instance is to use the :ref:`template string literal syntax <t-strings>`. This syntax is identical to that of :ref:`f...
python, official-docs, cpython, P0
Local_Trusted_Corpus
db604b28-6752-437d-8825-61b5500ce1af
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,254
supabase-export-v2
4c8540d8af3b8ed2
>>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.interpolations (Interpolation('Camembert', 'cheese', None, ''),) The ``interpolations`` tuple may be empty and always contains one fewer values than the ``strings`` tuple:
trusted_official_docs
CPython Docs
>>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.interpolations (Interpolation('Camembert', 'cheese', None, ''),) The ``interpolations`` tuple may be empty and always contains one fewer values than the ``strings`` tuple:
>>> cheese = 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.interpolations (Interpolation('Camembert', 'cheese', None, ''),) The ``interpolations`` tuple may be empty and always contains one fewer values than the ``strings`` tuple:
python, official-docs, cpython, P0
Local_Trusted_Corpus
dc95cfe8-7735-4cbe-a20b-2a00f70fc770
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,238
supabase-export-v2
c29e8ad7f5ee16ed
>>> cheese = 'Red Leicester' >>> template = t"We're fresh out of {cheese}, sir." >>> type(template) <class 'string.templatelib.Template'> Templates are stored as sequences of literal :attr:`~Template.strings` and dynamic :attr:`~Template.interpolations`. A :attr:`~Template.values` attribute holds the values of the int...
trusted_official_docs
CPython Docs
>>> cheese = 'Red Leicester' >>> template = t"We're fresh out of {cheese}, sir." >>> type(template) <class 'string.templatelib.Template'> Templates are stored as sequences of literal :attr:`~Template.strings` and dynamic :attr:`~Template.interpolations`. A :attr:`~Template.values` attribute holds the values of the int...
>>> cheese = 'Red Leicester' >>> template = t"We're fresh out of {cheese}, sir." >>> type(template) <class 'string.templatelib.Template'> Templates are stored as sequences of literal :attr:`~Template.strings` and dynamic :attr:`~Template.interpolations`. A :attr:`~Template.values` attribute holds the values of the int...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e00923e4-b2f3-4095-b802-b1bab0df78ac
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,277
supabase-export-v2
781bebfaa9fd7ffa
>>> cheese = 'Camembert' >>> list(t'Ah! ' + t'We do have {cheese}.') ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.'] Concatenating a :class:`!Template` and a ``str`` is **not** supported. This is because it is unclear whether the string should be treated as a static string or an interpolation....
trusted_official_docs
CPython Docs
>>> cheese = 'Camembert' >>> list(t'Ah! ' + t'We do have {cheese}.') ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.'] Concatenating a :class:`!Template` and a ``str`` is **not** supported. This is because it is unclear whether the string should be treated as a static string or an interpolation....
>>> cheese = 'Camembert' >>> list(t'Ah! ' + t'We do have {cheese}.') ['Ah! We do have ', Interpolation('Camembert', 'cheese', None, ''), '.'] Concatenating a :class:`!Template` and a ``str`` is **not** supported. This is because it is unclear whether the string should be treated as a static string or an interpolation....
python, official-docs, cpython, P0
Local_Trusted_Corpus
ee4976d4-abf1-47d1-90cb-3e48f5f0a3b7
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,240
supabase-export-v2
0266530f15f36cdb
= 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.strings ('Ah! We do have ', '.') >>> template.interpolations (Interpolation('Camembert', ...),) >>> template.values ('Camembert',) The :attr:`!strings` tuple has one more element than :attr:`!interpolations` and :attr:`!values`; the interpolations “...
trusted_official_docs
CPython Docs
= 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.strings ('Ah! We do have ', '.') >>> template.interpolations (Interpolation('Camembert', ...),) >>> template.values ('Camembert',) The :attr:`!strings` tuple has one more element than :attr:`!interpolations` and :attr:`!values`; the interpolations “...
= 'Camembert' >>> template = t'Ah! We do have {cheese}.' >>> template.strings ('Ah! We do have ', '.') >>> template.interpolations (Interpolation('Camembert', ...),) >>> template.values ('Camembert',) The :attr:`!strings` tuple has one more element than :attr:`!interpolations` and :attr:`!values`; the interpolations “...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f97997b8-2866-4148-bfe2-f1dc77a457fd
CPython Docs
file://datasets/cpython/Doc/library/string.templatelib.rst
unknown
fd9bc35b-614c-4ee3-9dc6-ac88639167fa
28,289
supabase-export-v2
b9fffbc32d976e88
the first ``!``, ``:``, or ``=`` if any is present. For manually created interpolations, :attr:`!expression` is the arbitrary string provided when constructing the interpolation instance. We recommend using valid Python expressions or the empty string for the ``expression`` field of manually created :class:`!Interpola...
trusted_official_docs
CPython Docs
the first ``!``, ``:``, or ``=`` if any is present. For manually created interpolations, :attr:`!expression` is the arbitrary string provided when constructing the interpolation instance. We recommend using valid Python expressions or the empty string for the ``expression`` field of manually created :class:`!Interpola...
the first ``!``, ``:``, or ``=`` if any is present. For manually created interpolations, :attr:`!expression` is the arbitrary string provided when constructing the interpolation instance. We recommend using valid Python expressions or the empty string for the ``expression`` field of manually created :class:`!Interpola...
python, official-docs, cpython, P0
Local_Trusted_Corpus
06b0c5de-7fe3-4393-b6f3-cb720b50ef59
CPython Docs
file://datasets/cpython/Doc/library/mailcap.rst
unknown
21d3cdbe-6687-45b9-bc7b-b9eba0c23a6c
28,317
supabase-export-v2
d617e1f91f443f4c
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:`!mailcap` module was `Python 3.12 <https://docs.python.org/3.12/library/mailcap.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:`!mailcap` module was `Python 3.12 <https://docs.python.org/3.12/library/mailcap.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:`!mailcap` module was `Python 3.12 <https://docs.python.org/3.12/library/mailcap.html>`_.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e6778f66-5a23-4c41-9dd5-5fdd44928c66
CPython Docs
file://datasets/cpython/Doc/library/xdrlib.rst
unknown
8c0677a3-08bf-4c7d-94cd-713f7856abe1
28,322
supabase-export-v2
fd68642cd0d5d3cc
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:`!xdrlib` module was `Python 3.12 <https://docs.python.org/3.12/library/xdrlib.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:`!xdrlib` module was `Python 3.12 <https://docs.python.org/3.12/library/xdrlib.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:`!xdrlib` module was `Python 3.12 <https://docs.python.org/3.12/library/xdrlib.html>`_.
python, official-docs, cpython, P0
Local_Trusted_Corpus
055db41b-3e40-4985-a4d4-00063b685aa4
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,342
supabase-export-v2
3e703cf22a984bd0
the server to proxy TCP through WebSockets; see `Emscripten Networking`_ for more information. WASI snapshot preview 1 only permits sockets from an existing file descriptor. * Some functions are stubs that either don't do anything and always return hardcoded values.
trusted_official_docs
CPython Docs
the server to proxy TCP through WebSockets; see `Emscripten Networking`_ for more information. WASI snapshot preview 1 only permits sockets from an existing file descriptor. * Some functions are stubs that either don't do anything and always return hardcoded values.
the server to proxy TCP through WebSockets; see `Emscripten Networking`_ for more information. WASI snapshot preview 1 only permits sockets from an existing file descriptor. * Some functions are stubs that either don't do anything and always return hardcoded values.
python, official-docs, cpython, P0
Local_Trusted_Corpus
2507c966-ab88-4b60-afdf-fefb74230741
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,327
supabase-export-v2
76c95cb7edba2075
:keyword:`import` statement. Some of these are defined by the core language, but many are not essential for the core semantics and are only described here. The bulk of the library, however, consists of a collection of modules. There are many ways to dissect this collection. Some modules are written in C and built in to...
trusted_official_docs
CPython Docs
:keyword:`import` statement. Some of these are defined by the core language, but many are not essential for the core semantics and are only described here. The bulk of the library, however, consists of a collection of modules. There are many ways to dissect this collection. Some modules are written in C and built in to...
:keyword:`import` statement. Some of these are defined by the core language, but many are not essential for the core semantics and are only described here. The bulk of the library, however, consists of a collection of modules. There are many ways to dissect this collection. Some modules are written in C and built in to...
python, official-docs, cpython, P0
Local_Trusted_Corpus
35f3d73a-c41f-4308-aa91-e06ada37d733
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,356
supabase-export-v2
de13b673ac0cf806
user who has installed your app provides their app logs as a diagnostic aid, they will not include any detail written to ``stdout`` or ``stderr``. * Mobile apps have no usable ``stdin`` at all. While apps can display an on-screen keyboard, this is a software feature, not something that is attached to ``stdin``.
trusted_official_docs
CPython Docs
user who has installed your app provides their app logs as a diagnostic aid, they will not include any detail written to ``stdout`` or ``stderr``. * Mobile apps have no usable ``stdin`` at all. While apps can display an on-screen keyboard, this is a software feature, not something that is attached to ``stdin``.
user who has installed your app provides their app logs as a diagnostic aid, they will not include any detail written to ``stdout`` or ``stderr``. * Mobile apps have no usable ``stdin`` at all. While apps can display an on-screen keyboard, this is a software feature, not something that is attached to ``stdin``.
python, official-docs, cpython, P0
Local_Trusted_Corpus
3a399800-9792-408a-9968-0a69456ff64c
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,337
supabase-export-v2
70ac812c690e83cb
WebAssembly platforms --------------------- The `WebAssembly`_ platforms ``wasm32-emscripten`` (`Emscripten`_) and ``wasm32-wasi`` (`WASI`_) provide a subset of POSIX APIs. WebAssembly runtimes and browsers are sandboxed and have limited access to the host and external resources. Any Python standard library module that...
trusted_official_docs
CPython Docs
WebAssembly platforms --------------------- The `WebAssembly`_ platforms ``wasm32-emscripten`` (`Emscripten`_) and ``wasm32-wasi`` (`WASI`_) provide a subset of POSIX APIs. WebAssembly runtimes and browsers are sandboxed and have limited access to the host and external resources. Any Python standard library module that...
WebAssembly platforms --------------------- The `WebAssembly`_ platforms ``wasm32-emscripten`` (`Emscripten`_) and ``wasm32-wasi`` (`WASI`_) provide a subset of POSIX APIs. WebAssembly runtimes and browsers are sandboxed and have limited access to the host and external resources. Any Python standard library module that...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3e01c3cd-0900-4adf-abd3-13dbaeac58f4
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,341
supabase-export-v2
5c4f0cab2c9d5fd4
spawn new processes (:func:`~os.fork`, :func:`~os.execve`), wait for processes (:func:`~os.waitpid`), send signals (:func:`~os.kill`), or otherwise interact with processes. The :mod:`subprocess` is importable but does not work. * The :mod:`socket` module is available, but is limited and behaves differently from other ...
trusted_official_docs
CPython Docs
spawn new processes (:func:`~os.fork`, :func:`~os.execve`), wait for processes (:func:`~os.waitpid`), send signals (:func:`~os.kill`), or otherwise interact with processes. The :mod:`subprocess` is importable but does not work. * The :mod:`socket` module is available, but is limited and behaves differently from other ...
spawn new processes (:func:`~os.fork`, :func:`~os.execve`), wait for processes (:func:`~os.waitpid`), send signals (:func:`~os.kill`), or otherwise interact with processes. The :mod:`subprocess` is importable but does not work. * The :mod:`socket` module is available, but is limited and behaves differently from other ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3f1638ff-d808-4dc8-bc88-b9dd4d5ade8b
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,350
supabase-export-v2
3063961ee0539a88
* Subprocesses: * On Android, creating subprocesses is possible but `officially unsupported <https://issuetracker.google.com/issues/128554619#comment4>`__. In particular, Android does not support any part of the System V IPC API, so :mod:`multiprocessing` is not available.
trusted_official_docs
CPython Docs
* Subprocesses: * On Android, creating subprocesses is possible but `officially unsupported <https://issuetracker.google.com/issues/128554619#comment4>`__. In particular, Android does not support any part of the System V IPC API, so :mod:`multiprocessing` is not available.
* Subprocesses: * On Android, creating subprocesses is possible but `officially unsupported <https://issuetracker.google.com/issues/128554619#comment4>`__. In particular, Android does not support any part of the System V IPC API, so :mod:`multiprocessing` is not available.
python, official-docs, cpython, P0
Local_Trusted_Corpus
41665516-cb6d-4260-9788-ef98199e64e5
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,352
supabase-export-v2
1af602c827559476
of other applications that are running, nor any ability to communicate with other running applications, outside of the iOS-specific APIs that exist for this purpose. * Mobile apps have limited access to modify system resources (such as the system clock). These resources will often be *readable*, but attempts to modify...
trusted_official_docs
CPython Docs
of other applications that are running, nor any ability to communicate with other running applications, outside of the iOS-specific APIs that exist for this purpose. * Mobile apps have limited access to modify system resources (such as the system clock). These resources will often be *readable*, but attempts to modify...
of other applications that are running, nor any ability to communicate with other running applications, outside of the iOS-specific APIs that exist for this purpose. * Mobile apps have limited access to modify system resources (such as the system clock). These resources will often be *readable*, but attempts to modify...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7dc9af64-4906-4870-9dcb-7968b698f3d9
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,334
supabase-export-v2
a8e3880fcd3a4e92
If not separately noted, all functions that claim "Availability: Unix" are supported on macOS, iOS and Android, all of which build on a Unix core. * If an availability note contains both a minimum Kernel version and a minimum libc version, then both conditions must hold. For example a feature with note *Availability:...
trusted_official_docs
CPython Docs
If not separately noted, all functions that claim "Availability: Unix" are supported on macOS, iOS and Android, all of which build on a Unix core. * If an availability note contains both a minimum Kernel version and a minimum libc version, then both conditions must hold. For example a feature with note *Availability:...
If not separately noted, all functions that claim "Availability: Unix" are supported on macOS, iOS and Android, all of which build on a Unix core. * If an availability note contains both a minimum Kernel version and a minimum libc version, then both conditions must hold. For example a feature with note *Availability:...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7f4799de-64af-4484-9925-7aa8cd6cb414
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,348
supabase-export-v2
fc8a542cc41cfdff
POSIX operating systems. File I/O, socket handling, and threading all behave as they would on any POSIX operating system. However, there are several major differences: * Mobile platforms can only use Python in "embedded" mode. There is no Python REPL, and no ability to use separate executables such as :program:`python...
trusted_official_docs
CPython Docs
POSIX operating systems. File I/O, socket handling, and threading all behave as they would on any POSIX operating system. However, there are several major differences: * Mobile platforms can only use Python in "embedded" mode. There is no Python REPL, and no ability to use separate executables such as :program:`python...
POSIX operating systems. File I/O, socket handling, and threading all behave as they would on any POSIX operating system. However, there are several major differences: * Mobile platforms can only use Python in "embedded" mode. There is no Python REPL, and no ability to use separate executables such as :program:`python...
python, official-docs, cpython, P0
Local_Trusted_Corpus
94a6e34d-8b27-4389-ab5d-699a7e18c8e2
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,338
supabase-export-v2
f37c06a96e538df4
file system, and Unix permission-related functions are restricted, too. Emscripten does not permit blocking I/O. Other blocking operations like :func:`~time.sleep` block the browser event loop. The properties and behavior of Python on WebAssembly platforms depend on the `Emscripten`_-SDK or `WASI`_-SDK version, WASM ru...
trusted_official_docs
CPython Docs
file system, and Unix permission-related functions are restricted, too. Emscripten does not permit blocking I/O. Other blocking operations like :func:`~time.sleep` block the browser event loop. The properties and behavior of Python on WebAssembly platforms depend on the `Emscripten`_-SDK or `WASI`_-SDK version, WASM ru...
file system, and Unix permission-related functions are restricted, too. Emscripten does not permit blocking I/O. Other blocking operations like :func:`~time.sleep` block the browser event loop. The properties and behavior of Python on WebAssembly platforms depend on the `Emscripten`_-SDK or `WASI`_-SDK version, WASM ru...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a129038d-3433-4eeb-80e0-8feab65f850f
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,326
supabase-export-v2
49ff99aecd767565
but does not fully define the semantics. (On the other hand, the language core does define syntactic properties like the spelling and priorities of operators.) The library also contains built-in functions and exceptions --- objects that can be used by all Python code without the need of an :keyword:`import` statement. ...
trusted_official_docs
CPython Docs
but does not fully define the semantics. (On the other hand, the language core does define syntactic properties like the spelling and priorities of operators.) The library also contains built-in functions and exceptions --- objects that can be used by all Python code without the need of an :keyword:`import` statement. ...
but does not fully define the semantics. (On the other hand, the language core does define syntactic properties like the spelling and priorities of operators.) The library also contains built-in functions and exceptions --- objects that can be used by all Python code without the need of an :keyword:`import` statement. ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a8f8923b-1a8f-402a-b8f8-31ce6889cef2
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,343
supabase-export-v2
9138fd1fabf1834c
* Some functions are stubs that either don't do anything and always return hardcoded values. * Functions related to file descriptors, file permissions, file ownership, and links are limited and don't support some operations. For example, WASI does not permit symlinks with absolute file names.
trusted_official_docs
CPython Docs
* Some functions are stubs that either don't do anything and always return hardcoded values. * Functions related to file descriptors, file permissions, file ownership, and links are limited and don't support some operations. For example, WASI does not permit symlinks with absolute file names.
* Some functions are stubs that either don't do anything and always return hardcoded values. * Functions related to file descriptors, file permissions, file ownership, and links are limited and don't support some operations. For example, WASI does not permit symlinks with absolute file names.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b5c11d17-f143-4021-960f-b62b872c30cb
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,347
supabase-export-v2
1f08dbb7ec59c3d6
Mobile platforms ---------------- Android and iOS are, in most respects, POSIX operating systems. File I/O, socket handling, and threading all behave as they would on any POSIX operating system. However, there are several major differences:
trusted_official_docs
CPython Docs
Mobile platforms ---------------- Android and iOS are, in most respects, POSIX operating systems. File I/O, socket handling, and threading all behave as they would on any POSIX operating system. However, there are several major differences:
Mobile platforms ---------------- Android and iOS are, in most respects, POSIX operating systems. File I/O, socket handling, and threading all behave as they would on any POSIX operating system. However, there are several major differences:
python, official-docs, cpython, P0
Local_Trusted_Corpus
bf321282-33bc-4416-9f1a-9264e22f9c4e
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,357
supabase-export-v2
3be903a60f6b6e8f
have no usable ``stdin`` at all. While apps can display an on-screen keyboard, this is a software feature, not something that is attached to ``stdin``. As a result, Python modules that involve console manipulation (such as :mod:`curses` and :mod:`readline`) are not available on mobile platforms.
trusted_official_docs
CPython Docs
have no usable ``stdin`` at all. While apps can display an on-screen keyboard, this is a software feature, not something that is attached to ``stdin``. As a result, Python modules that involve console manipulation (such as :mod:`curses` and :mod:`readline`) are not available on mobile platforms.
have no usable ``stdin`` at all. While apps can display an on-screen keyboard, this is a software feature, not something that is attached to ``stdin``. As a result, Python modules that involve console manipulation (such as :mod:`curses` and :mod:`readline`) are not available on mobile platforms.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c0576533-34fd-4026-9048-bc5b8abc9662
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,354
supabase-export-v2
f037c0a529285481
* Console input and output: * On Android, the native ``stdout`` and ``stderr`` are not connected to anything, so Python installs its own streams which redirect messages to the system log. These can be seen under the tags ``python.stdout`` and ``python.stderr`` respectively.
trusted_official_docs
CPython Docs
* Console input and output: * On Android, the native ``stdout`` and ``stderr`` are not connected to anything, so Python installs its own streams which redirect messages to the system log. These can be seen under the tags ``python.stdout`` and ``python.stderr`` respectively.
* Console input and output: * On Android, the native ``stdout`` and ``stderr`` are not connected to anything, so Python installs its own streams which redirect messages to the system log. These can be seen under the tags ``python.stdout`` and ``python.stderr`` respectively.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c66fcc44-1df0-475d-b925-6b2004879217
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,355
supabase-export-v2
fe4608ca4a9f1f09
anything, so Python installs its own streams which redirect messages to the system log. These can be seen under the tags ``python.stdout`` and ``python.stderr`` respectively. * iOS apps have a limited concept of console output. ``stdout`` and ``stderr`` *exist*, and content written to ``stdout`` and ``stderr`` will be...
trusted_official_docs
CPython Docs
anything, so Python installs its own streams which redirect messages to the system log. These can be seen under the tags ``python.stdout`` and ``python.stderr`` respectively. * iOS apps have a limited concept of console output. ``stdout`` and ``stderr`` *exist*, and content written to ``stdout`` and ``stderr`` will be...
anything, so Python installs its own streams which redirect messages to the system log. These can be seen under the tags ``python.stdout`` and ``python.stderr`` respectively. * iOS apps have a limited concept of console output. ``stdout`` and ``stderr`` *exist*, and content written to ``stdout`` and ``stderr`` will be...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c6bde376-0507-4c60-ad28-e4a2df1e25ce
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,340
supabase-export-v2
a7e8e25126d43e04
of CPython and Emscripten. Pyodide provides access to browsers' JavaScript and DOM APIs as well as limited networking capabilities with JavaScript's ``XMLHttpRequest`` and ``Fetch`` APIs. * Process-related APIs are not available or always fail with an error. That includes APIs that spawn new processes (:func:`~os.fork...
trusted_official_docs
CPython Docs
of CPython and Emscripten. Pyodide provides access to browsers' JavaScript and DOM APIs as well as limited networking capabilities with JavaScript's ``XMLHttpRequest`` and ``Fetch`` APIs. * Process-related APIs are not available or always fail with an error. That includes APIs that spawn new processes (:func:`~os.fork...
of CPython and Emscripten. Pyodide provides access to browsers' JavaScript and DOM APIs as well as limited networking capabilities with JavaScript's ``XMLHttpRequest`` and ``Fetch`` APIs. * Process-related APIs are not available or always fail with an error. That includes APIs that spawn new processes (:func:`~os.fork...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c7e885f1-16ff-4d7a-903d-7f6ae2a65097
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,325
supabase-export-v2
33ad85cc8d8eb9b4
The "Python library" contains several different kinds of components. It contains data types that would normally be considered part of the "core" of a language, such as numbers and lists. For these types, the Python language core defines the form of literals and places some constraints on their semantics, but does not f...
trusted_official_docs
CPython Docs
The "Python library" contains several different kinds of components. It contains data types that would normally be considered part of the "core" of a language, such as numbers and lists. For these types, the Python language core defines the form of literals and places some constraints on their semantics, but does not f...
The "Python library" contains several different kinds of components. It contains data types that would normally be considered part of the "core" of a language, such as numbers and lists. For these types, the Python language core defines the form of literals and places some constraints on their semantics, but does not f...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cbb18372-63cb-4591-b2ac-3950147e5591
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,332
supabase-export-v2
86c07c8e1645abb7
Notes on availability ===================== * An "Availability: Unix" note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system.
trusted_official_docs
CPython Docs
Notes on availability ===================== * An "Availability: Unix" note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system.
Notes on availability ===================== * An "Availability: Unix" note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system.
python, official-docs, cpython, P0
Local_Trusted_Corpus
cbee6006-a54b-48d4-990b-79117285342a
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,344
supabase-export-v2
f58853248cb10d54
descriptors, file permissions, file ownership, and links are limited and don't support some operations. For example, WASI does not permit symlinks with absolute file names. .. _WebAssembly: https://webassembly.org/ .. _Emscripten: https://emscripten.org/ .. _Emscripten Networking: https://emscripten.org/docs/porting/ne...
trusted_official_docs
CPython Docs
descriptors, file permissions, file ownership, and links are limited and don't support some operations. For example, WASI does not permit symlinks with absolute file names. .. _WebAssembly: https://webassembly.org/ .. _Emscripten: https://emscripten.org/ .. _Emscripten Networking: https://emscripten.org/docs/porting/ne...
descriptors, file permissions, file ownership, and links are limited and don't support some operations. For example, WASI does not permit symlinks with absolute file names. .. _WebAssembly: https://webassembly.org/ .. _Emscripten: https://emscripten.org/ .. _Emscripten Networking: https://emscripten.org/docs/porting/ne...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ce9cefb7-6f19-4d24-8b7a-1319443cfe7f
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,333
supabase-export-v2
28edab4d44ca8a38
note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system. * If not separately noted, all functions that claim "Availability: Unix" are supported on macOS, iOS and Android, all of which build on a Unix core.
trusted_official_docs
CPython Docs
note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system. * If not separately noted, all functions that claim "Availability: Unix" are supported on macOS, iOS and Android, all of which build on a Unix core.
note means that this function is commonly found on Unix systems. It does not make any claims about its existence on a specific operating system. * If not separately noted, all functions that claim "Availability: Unix" are supported on macOS, iOS and Android, all of which build on a Unix core.
python, official-docs, cpython, P0
Local_Trusted_Corpus
d8c98e40-d215-4455-9d1e-8cfec8b1a6d4
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,339
supabase-export-v2
f7af1a2529ea9306
(browser, NodeJS, `wasmtime`_), and Python build time flags. WebAssembly, Emscripten, and WASI are evolving standards; some features like networking may be supported in the future. For Python in the browser, users should consider `Pyodide`_ or `PyScript`_. PyScript is built on top of Pyodide, which itself is built on t...
trusted_official_docs
CPython Docs
(browser, NodeJS, `wasmtime`_), and Python build time flags. WebAssembly, Emscripten, and WASI are evolving standards; some features like networking may be supported in the future. For Python in the browser, users should consider `Pyodide`_ or `PyScript`_. PyScript is built on top of Pyodide, which itself is built on t...
(browser, NodeJS, `wasmtime`_), and Python build time flags. WebAssembly, Emscripten, and WASI are evolving standards; some features like networking may be supported in the future. For Python in the browser, users should consider `Pyodide`_ or `PyScript`_. PyScript is built on top of Pyodide, which itself is built on t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e4bbd846-9599-4723-a180-e8719f654f91
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,328
supabase-export-v2
7984852d1270bafd
supports or requires them; yet others are available only when a particular configuration option was chosen at the time when Python was compiled and installed. This manual is organized "from the inside out:" it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapter...
trusted_official_docs
CPython Docs
supports or requires them; yet others are available only when a particular configuration option was chosen at the time when Python was compiled and installed. This manual is organized "from the inside out:" it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapter...
supports or requires them; yet others are available only when a particular configuration option was chosen at the time when Python was compiled and installed. This manual is organized "from the inside out:" it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapter...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e8601677-b37b-4078-ac61-1620b98f8396
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,353
supabase-export-v2
a66c871aa6b6c1e6
access to modify system resources (such as the system clock). These resources will often be *readable*, but attempts to modify those resources will usually fail. * Console input and output:
trusted_official_docs
CPython Docs
access to modify system resources (such as the system clock). These resources will often be *readable*, but attempts to modify those resources will usually fail. * Console input and output:
access to modify system resources (such as the system clock). These resources will often be *readable*, but attempts to modify those resources will usually fail. * Console input and output:
python, official-docs, cpython, P0
Local_Trusted_Corpus
f545319f-105e-4e44-91e3-9d56c2f19d06
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,351
supabase-export-v2
324f582311cf58ff
is possible but `officially unsupported <https://issuetracker.google.com/issues/128554619#comment4>`__. In particular, Android does not support any part of the System V IPC API, so :mod:`multiprocessing` is not available. * An iOS app cannot use any form of subprocessing, multiprocessing, or inter-process communicatio...
trusted_official_docs
CPython Docs
is possible but `officially unsupported <https://issuetracker.google.com/issues/128554619#comment4>`__. In particular, Android does not support any part of the System V IPC API, so :mod:`multiprocessing` is not available. * An iOS app cannot use any form of subprocessing, multiprocessing, or inter-process communicatio...
is possible but `officially unsupported <https://issuetracker.google.com/issues/128554619#comment4>`__. In particular, Android does not support any part of the System V IPC API, so :mod:`multiprocessing` is not available. * An iOS app cannot use any form of subprocessing, multiprocessing, or inter-process communicatio...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fbec5308-1e0f-4ede-9c9c-7445e83ca0d7
CPython Docs
file://datasets/cpython/Doc/library/intro.rst
unknown
4932be5e-2c0d-4bf5-9478-81cea1f746e1
28,329
supabase-export-v2
109aa2e51c0baa77
organized "from the inside out:" it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapters of related modules. This means that if you start reading this manual from the start, and skip to the next chapter when you get bored, you will get a reasonable overview of ...
trusted_official_docs
CPython Docs
organized "from the inside out:" it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapters of related modules. This means that if you start reading this manual from the start, and skip to the next chapter when you get bored, you will get a reasonable overview of ...
organized "from the inside out:" it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapters of related modules. This means that if you start reading this manual from the start, and skip to the next chapter when you get bored, you will get a reasonable overview of ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
02b90bdb-de76-4a04-b477-8c32207e23f5
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,545
supabase-export-v2
da6cb28ee7e57f69
Continuing the example for :func:`asynccontextmanager`:: async with AsyncExitStack() as stack: connections = [await stack.enter_async_context(get_connection()) for i in range(5)] # All opened connections will automatically be released at the end of # the async with statement, even if attempts to open a connection ...
trusted_official_docs
CPython Docs
Continuing the example for :func:`asynccontextmanager`:: async with AsyncExitStack() as stack: connections = [await stack.enter_async_context(get_connection()) for i in range(5)] # All opened connections will automatically be released at the end of # the async with statement, even if attempts to open a connection ...
Continuing the example for :func:`asynccontextmanager`:: async with AsyncExitStack() as stack: connections = [await stack.enter_async_context(get_connection()) for i in range(5)] # All opened connections will automatically be released at the end of # the async with statement, even if attempts to open a connection ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
02ce469b-a189-404f-8055-ddb24ab773a8
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,411
supabase-export-v2
89fcb18990c1b5ac
@asynccontextmanager async def aclosing(thing): try: yield thing finally: await thing.aclose() Significantly, ``aclosing()`` supports deterministic cleanup of async generators when they happen to exit early by :keyword:`break` or an exception. For example::
trusted_official_docs
CPython Docs
@asynccontextmanager async def aclosing(thing): try: yield thing finally: await thing.aclose() Significantly, ``aclosing()`` supports deterministic cleanup of async generators when they happen to exit early by :keyword:`break` or an exception. For example::
@asynccontextmanager async def aclosing(thing): try: yield thing finally: await thing.aclose() Significantly, ``aclosing()`` supports deterministic cleanup of async generators when they happen to exit early by :keyword:`break` or an exception. For example::
python, official-docs, cpython, P0
Local_Trusted_Corpus
0be1fd80-bafc-40d2-9710-64c7ad049841
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,586
supabase-export-v2
c10eed597174f5ae
exit. Rather than writing both a function decorator and a context manager for the task, inheriting from :class:`ContextDecorator` provides both capabilities in a single definition:: from contextlib import ContextDecorator import logging
trusted_official_docs
CPython Docs
exit. Rather than writing both a function decorator and a context manager for the task, inheriting from :class:`ContextDecorator` provides both capabilities in a single definition:: from contextlib import ContextDecorator import logging
exit. Rather than writing both a function decorator and a context manager for the task, inheriting from :class:`ContextDecorator` provides both capabilities in a single definition:: from contextlib import ContextDecorator import logging
python, official-docs, cpython, P0
Local_Trusted_Corpus
0dfc0b94-75b8-4535-86c3-a24b06d6a142
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,451
supabase-export-v2
15c587d902ec9023
and most threaded applications. It also has no effect on the output of subprocesses. However, it is still a useful approach for many utility scripts. This context manager is :ref:`reentrant <reentrant-cms>`.
trusted_official_docs
CPython Docs
and most threaded applications. It also has no effect on the output of subprocesses. However, it is still a useful approach for many utility scripts. This context manager is :ref:`reentrant <reentrant-cms>`.
and most threaded applications. It also has no effect on the output of subprocesses. However, it is still a useful approach for many utility scripts. This context manager is :ref:`reentrant <reentrant-cms>`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
10d74a9a-f3ee-45e4-8930-58b3f51ba860
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,565
supabase-export-v2
43e0e7d177a24346
def __enter__(self): resource = self.acquire_resource() with self._cleanup_on_error(): if not self.check_resource_ok(resource): msg = "Failed validation for {!r}" raise RuntimeError(msg.format(resource)) return resource def __exit__(self, *exc_details): # We don't need to duplicate any of our resource release logic s...
trusted_official_docs
CPython Docs
def __enter__(self): resource = self.acquire_resource() with self._cleanup_on_error(): if not self.check_resource_ok(resource): msg = "Failed validation for {!r}" raise RuntimeError(msg.format(resource)) return resource def __exit__(self, *exc_details): # We don't need to duplicate any of our resource release logic s...
def __enter__(self): resource = self.acquire_resource() with self._cleanup_on_error(): if not self.check_resource_ok(resource): msg = "Failed validation for {!r}" raise RuntimeError(msg.format(resource)) return resource def __exit__(self, *exc_details): # We don't need to duplicate any of our resource release logic s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
135a3552-df4d-4afd-a7cd-f5ef017f54f5
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,607
supabase-export-v2
d7d6cc72137b6e33
Reentrant context managers ^^^^^^^^^^^^^^^^^^^^^^^^^^ More sophisticated context managers may be "reentrant". These context managers can not only be used in multiple :keyword:`with` statements, but may also be used *inside* a :keyword:`!with` statement that is already using the same context manager.
trusted_official_docs
CPython Docs
Reentrant context managers ^^^^^^^^^^^^^^^^^^^^^^^^^^ More sophisticated context managers may be "reentrant". These context managers can not only be used in multiple :keyword:`with` statements, but may also be used *inside* a :keyword:`!with` statement that is already using the same context manager.
Reentrant context managers ^^^^^^^^^^^^^^^^^^^^^^^^^^ More sophisticated context managers may be "reentrant". These context managers can not only be used in multiple :keyword:`with` statements, but may also be used *inside* a :keyword:`!with` statement that is already using the same context manager.
python, official-docs, cpython, P0
Local_Trusted_Corpus
13be839d-2bf6-4f9c-95db-a54d6a755b6d
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,463
supabase-export-v2
ffa66ac5d7653739
A base class that enables a context manager to also be used as a decorator. Context managers inheriting from ``ContextDecorator`` have to implement :meth:`~object.__enter__` and :meth:`~object.__exit__` as normal. ``__exit__`` retains its optional exception handling even when used as a decorator.
trusted_official_docs
CPython Docs
A base class that enables a context manager to also be used as a decorator. Context managers inheriting from ``ContextDecorator`` have to implement :meth:`~object.__enter__` and :meth:`~object.__exit__` as normal. ``__exit__`` retains its optional exception handling even when used as a decorator.
A base class that enables a context manager to also be used as a decorator. Context managers inheriting from ``ContextDecorator`` have to implement :meth:`~object.__enter__` and :meth:`~object.__exit__` as normal. ``__exit__`` retains its optional exception handling even when used as a decorator.
python, official-docs, cpython, P0
Local_Trusted_Corpus
14869d47-7ffd-4ed5-a3cf-06ea5f902d34
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,485
supabase-export-v2
1682a5e50da8036c
.. versionadded:: 3.2 .. versionchanged:: next Decorating a generator function, coroutine function, or asynchronous generator function now keeps the context manager open across iteration or await. Previously the context manager exited as soon as the generator or coroutine object was created.
trusted_official_docs
CPython Docs
.. versionadded:: 3.2 .. versionchanged:: next Decorating a generator function, coroutine function, or asynchronous generator function now keeps the context manager open across iteration or await. Previously the context manager exited as soon as the generator or coroutine object was created.
.. versionadded:: 3.2 .. versionchanged:: next Decorating a generator function, coroutine function, or asynchronous generator function now keeps the context manager open across iteration or await. Previously the context manager exited as soon as the generator or coroutine object was created.
python, official-docs, cpython, P0
Local_Trusted_Corpus
16363d6b-711d-4600-af82-7126fd78f27e
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,558
supabase-export-v2
09e652da449ec2b9
Cleaning up in an ``__enter__`` implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ As noted in the documentation of :meth:`ExitStack.push`, this method can be useful in cleaning up an already allocated resource if later steps in the :meth:`~object.__enter__` implementation fail.
trusted_official_docs
CPython Docs
Cleaning up in an ``__enter__`` implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ As noted in the documentation of :meth:`ExitStack.push`, this method can be useful in cleaning up an already allocated resource if later steps in the :meth:`~object.__enter__` implementation fail.
Cleaning up in an ``__enter__`` implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ As noted in the documentation of :meth:`ExitStack.push`, this method can be useful in cleaning up an already allocated resource if later steps in the :meth:`~object.__enter__` implementation fail.
python, official-docs, cpython, P0
Local_Trusted_Corpus
165fc672-ba6d-4f27-8778-2ac2c03674fd
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,424
supabase-export-v2
ac53afc706136d76
It can also be used as a stand-in for :ref:`asynchronous context managers <async-context-managers>`:: async def send_http(session=None): if not session: # If no http session, create it with aiohttp cm = aiohttp.ClientSession() else: # Caller is responsible for closing the session cm = nullcontext(session)
trusted_official_docs
CPython Docs
It can also be used as a stand-in for :ref:`asynchronous context managers <async-context-managers>`:: async def send_http(session=None): if not session: # If no http session, create it with aiohttp cm = aiohttp.ClientSession() else: # Caller is responsible for closing the session cm = nullcontext(session)
It can also be used as a stand-in for :ref:`asynchronous context managers <async-context-managers>`:: async def send_http(session=None): if not session: # If no http session, create it with aiohttp cm = aiohttp.ClientSession() else: # Caller is responsible for closing the session cm = nullcontext(session)
python, official-docs, cpython, P0
Local_Trusted_Corpus
18a391d3-c318-4adc-95f2-c84c14238788
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,366
supabase-export-v2
a8df4563e2678ccb
.. class:: AbstractContextManager An :term:`abstract base class` for classes that implement :meth:`~object.__enter__` and :meth:`~object.__exit__`. A default implementation for :meth:`~object.__enter__` is provided which returns ``self`` while :meth:`~object.__exit__` is an abstract method which by default returns ...
trusted_official_docs
CPython Docs
.. class:: AbstractContextManager An :term:`abstract base class` for classes that implement :meth:`~object.__enter__` and :meth:`~object.__exit__`. A default implementation for :meth:`~object.__enter__` is provided which returns ``self`` while :meth:`~object.__exit__` is an abstract method which by default returns ...
.. class:: AbstractContextManager An :term:`abstract base class` for classes that implement :meth:`~object.__enter__` and :meth:`~object.__exit__`. A default implementation for :meth:`~object.__enter__` is provided which returns ``self`` while :meth:`~object.__exit__` is an abstract method which by default returns ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
196daf1c-6107-4353-881e-b8dc6e32320a
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,573
supabase-export-v2
7b3d90c8298f6a3a
with ExitStack() as stack: stack.callback(cleanup_resources) result = perform_operation() if result: stack.pop_all() This allows the intended cleanup behaviour to be made explicit up front, rather than requiring a separate flag variable.
trusted_official_docs
CPython Docs
with ExitStack() as stack: stack.callback(cleanup_resources) result = perform_operation() if result: stack.pop_all() This allows the intended cleanup behaviour to be made explicit up front, rather than requiring a separate flag variable.
with ExitStack() as stack: stack.callback(cleanup_resources) result = perform_operation() if result: stack.pop_all() This allows the intended cleanup behaviour to be made explicit up front, rather than requiring a separate flag variable.
python, official-docs, cpython, P0
Local_Trusted_Corpus
1d37b473-e611-4850-bb58-2e5de29c086a
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,518
supabase-export-v2
e06afbca21e75d1b
By returning true values, these callbacks can suppress exceptions the same way context manager :meth:`~object.__exit__` methods can. The passed in object is returned from the function, allowing this method to be used as a function decorator.
trusted_official_docs
CPython Docs
By returning true values, these callbacks can suppress exceptions the same way context manager :meth:`~object.__exit__` methods can. The passed in object is returned from the function, allowing this method to be used as a function decorator.
By returning true values, these callbacks can suppress exceptions the same way context manager :meth:`~object.__exit__` methods can. The passed in object is returned from the function, allowing this method to be used as a function decorator.
python, official-docs, cpython, P0
Local_Trusted_Corpus
1f6df846-9b04-496d-b842-e1de9942e26b
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,377
supabase-export-v2
50ea8f9cb4cc5b98
@contextmanager def managed_resource(*args, **kwds): # Code to acquire resource, e.g.: resource = acquire_resource(*args, **kwds) try: yield resource finally: # Code to release resource, e.g.: release_resource(resource) The function can then be used like this::
trusted_official_docs
CPython Docs
@contextmanager def managed_resource(*args, **kwds): # Code to acquire resource, e.g.: resource = acquire_resource(*args, **kwds) try: yield resource finally: # Code to release resource, e.g.: release_resource(resource) The function can then be used like this::
@contextmanager def managed_resource(*args, **kwds): # Code to acquire resource, e.g.: resource = acquire_resource(*args, **kwds) try: yield resource finally: # Code to release resource, e.g.: release_resource(resource) The function can then be used like this::
python, official-docs, cpython, P0
Local_Trusted_Corpus
1f790cc4-ff3e-45c6-a46c-3641cd942042
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,569
supabase-export-v2
6d418240f1c1e404
cleanup_needed = True try: result = perform_operation() if result: cleanup_needed = False finally: if cleanup_needed: cleanup_resources() As with any ``try`` statement based code, this can cause problems for development and review, because the setup code and the cleanup code can end up being separated by arbitrarily lo...
trusted_official_docs
CPython Docs
cleanup_needed = True try: result = perform_operation() if result: cleanup_needed = False finally: if cleanup_needed: cleanup_resources() As with any ``try`` statement based code, this can cause problems for development and review, because the setup code and the cleanup code can end up being separated by arbitrarily lo...
cleanup_needed = True try: result = perform_operation() if result: cleanup_needed = False finally: if cleanup_needed: cleanup_resources() As with any ``try`` statement based code, this can cause problems for development and review, because the setup code and the cleanup code can end up being separated by arbitrarily lo...
python, official-docs, cpython, P0
Local_Trusted_Corpus
200dd4b8-5873-4077-b77c-79e517ed6de3
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,525
supabase-export-v2
afd4ec66a245568d
.. method:: pop_all() Transfers the callback stack to a fresh :class:`ExitStack` instance and returns it. No callbacks are invoked by this operation - instead, they will now be invoked when the new stack is closed (either explicitly or implicitly at the end of a :keyword:`with` statement).
trusted_official_docs
CPython Docs
.. method:: pop_all() Transfers the callback stack to a fresh :class:`ExitStack` instance and returns it. No callbacks are invoked by this operation - instead, they will now be invoked when the new stack is closed (either explicitly or implicitly at the end of a :keyword:`with` statement).
.. method:: pop_all() Transfers the callback stack to a fresh :class:`ExitStack` instance and returns it. No callbacks are invoked by this operation - instead, they will now be invoked when the new stack is closed (either explicitly or implicitly at the end of a :keyword:`with` statement).
python, official-docs, cpython, P0
Local_Trusted_Corpus
20c7f2d5-f5b4-4049-8e20-b93a9cf943bf
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,608
supabase-export-v2
d0acb5d006a3cad2
not only be used in multiple :keyword:`with` statements, but may also be used *inside* a :keyword:`!with` statement that is already using the same context manager. :class:`threading.RLock` is an example of a reentrant context manager, as are :func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a very si...
trusted_official_docs
CPython Docs
not only be used in multiple :keyword:`with` statements, but may also be used *inside* a :keyword:`!with` statement that is already using the same context manager. :class:`threading.RLock` is an example of a reentrant context manager, as are :func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a very si...
not only be used in multiple :keyword:`with` statements, but may also be used *inside* a :keyword:`!with` statement that is already using the same context manager. :class:`threading.RLock` is an example of a reentrant context manager, as are :func:`suppress`, :func:`redirect_stdout`, and :func:`chdir`. Here's a very si...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2149a692-b025-48d8-8e98-39c6f657c102
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,563
supabase-export-v2
fcf05006957b09bb
def __init__(self, acquire_resource, release_resource, check_resource_ok=None): self.acquire_resource = acquire_resource self.release_resource = release_resource if check_resource_ok is None: def check_resource_ok(resource): return True self.check_resource_ok = check_resource_ok @contextmanager def _cleanup_on_error(s...
trusted_official_docs
CPython Docs
def __init__(self, acquire_resource, release_resource, check_resource_ok=None): self.acquire_resource = acquire_resource self.release_resource = release_resource if check_resource_ok is None: def check_resource_ok(resource): return True self.check_resource_ok = check_resource_ok @contextmanager def _cleanup_on_error(s...
def __init__(self, acquire_resource, release_resource, check_resource_ok=None): self.acquire_resource = acquire_resource self.release_resource = release_resource if check_resource_ok is None: def check_resource_ok(resource): return True self.check_resource_ok = check_resource_ok @contextmanager def _cleanup_on_error(s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2665e482-e1b4-4aaf-84a3-3967b1bc24ad
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,523
supabase-export-v2
b215d141842d0480
Unlike the other methods, callbacks added this way cannot suppress exceptions (as they are never passed the exception details). The passed in callback is returned from the function, allowing this method to be used as a function decorator.
trusted_official_docs
CPython Docs
Unlike the other methods, callbacks added this way cannot suppress exceptions (as they are never passed the exception details). The passed in callback is returned from the function, allowing this method to be used as a function decorator.
Unlike the other methods, callbacks added this way cannot suppress exceptions (as they are never passed the exception details). The passed in callback is returned from the function, allowing this method to be used as a function decorator.
python, official-docs, cpython, P0
Local_Trusted_Corpus
28ccccc1-ed00-476d-a5a2-5289886462d4
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,497
supabase-export-v2
550a019b83b9b30a
.. versionadded:: 3.10 .. versionchanged:: next Decorating an asynchronous generator function now keeps the context manager open across iteration. Previously the context manager exited as soon as the generator object was created. Synchronous functions and synchronous generator functions are also now accepted, with ...
trusted_official_docs
CPython Docs
.. versionadded:: 3.10 .. versionchanged:: next Decorating an asynchronous generator function now keeps the context manager open across iteration. Previously the context manager exited as soon as the generator object was created. Synchronous functions and synchronous generator functions are also now accepted, with ...
.. versionadded:: 3.10 .. versionchanged:: next Decorating an asynchronous generator function now keeps the context manager open across iteration. Previously the context manager exited as soon as the generator object was created. Synchronous functions and synchronous generator functions are also now accepted, with ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2999a1a5-4a2b-44a1-a5b0-11bbe24cd75d
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,414
supabase-export-v2
ec3cc1573debc92a
async with aclosing(my_generator()) as values: async for value in values: if value == 42: break This pattern ensures that the generator's async exit code is executed in the same context as its iterations (so that exceptions and context variables work as expected, and the exit code isn't run after the lifetime of som...
trusted_official_docs
CPython Docs
async with aclosing(my_generator()) as values: async for value in values: if value == 42: break This pattern ensures that the generator's async exit code is executed in the same context as its iterations (so that exceptions and context variables work as expected, and the exit code isn't run after the lifetime of som...
async with aclosing(my_generator()) as values: async for value in values: if value == 42: break This pattern ensures that the generator's async exit code is executed in the same context as its iterations (so that exceptions and context variables work as expected, and the exit code isn't run after the lifetime of som...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2ca165d9-07b7-4dc7-8738-415b898742a2
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,603
supabase-export-v2
a551ea93950f32fa
example of effectively single use context managers, since the first :keyword:`with` statement will close the file, preventing any further IO operations using that file object. Context managers created using :func:`contextmanager` are also single use context managers, and will complain about the underlying generator fai...
trusted_official_docs
CPython Docs
example of effectively single use context managers, since the first :keyword:`with` statement will close the file, preventing any further IO operations using that file object. Context managers created using :func:`contextmanager` are also single use context managers, and will complain about the underlying generator fai...
example of effectively single use context managers, since the first :keyword:`with` statement will close the file, preventing any further IO operations using that file object. Context managers created using :func:`contextmanager` are also single use context managers, and will complain about the underlying generator fai...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2d975fd0-5d9b-411a-8730-709632d69599
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,483
supabase-export-v2
59ad63efef642448
call that creates the generator or coroutine object. Wrapped generators and asynchronous generators are explicitly closed when iteration ends, as if by :func:`closing` or :func:`aclosing`. .. note:: For asynchronous generators the wrapper re-yields each value with ``async for``; values sent with :meth:`~agen.asend` a...
trusted_official_docs
CPython Docs
call that creates the generator or coroutine object. Wrapped generators and asynchronous generators are explicitly closed when iteration ends, as if by :func:`closing` or :func:`aclosing`. .. note:: For asynchronous generators the wrapper re-yields each value with ``async for``; values sent with :meth:`~agen.asend` a...
call that creates the generator or coroutine object. Wrapped generators and asynchronous generators are explicitly closed when iteration ends, as if by :func:`closing` or :func:`aclosing`. .. note:: For asynchronous generators the wrapper re-yields each value with ``async for``; values sent with :meth:`~agen.asend` a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2e770778-71c6-4b6e-940d-814fb2745cce
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,500
supabase-export-v2
de966ff53e02e6c1
designed to make it easy to programmatically combine other context managers and cleanup functions, especially those that are optional or otherwise driven by input data. For example, a set of files may easily be handled in a single with statement as follows::
trusted_official_docs
CPython Docs
designed to make it easy to programmatically combine other context managers and cleanup functions, especially those that are optional or otherwise driven by input data. For example, a set of files may easily be handled in a single with statement as follows::
designed to make it easy to programmatically combine other context managers and cleanup functions, especially those that are optional or otherwise driven by input data. For example, a set of files may easily be handled in a single with statement as follows::
python, official-docs, cpython, P0
Local_Trusted_Corpus
2ecb7d57-080b-4dd1-bcc1-bd5f4f9c0dd7
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,574
supabase-export-v2
86afe114d302f1ed
This allows the intended cleanup behaviour to be made explicit up front, rather than requiring a separate flag variable. If a particular application uses this pattern a lot, it can be simplified even further by means of a small helper class::
trusted_official_docs
CPython Docs
This allows the intended cleanup behaviour to be made explicit up front, rather than requiring a separate flag variable. If a particular application uses this pattern a lot, it can be simplified even further by means of a small helper class::
This allows the intended cleanup behaviour to be made explicit up front, rather than requiring a separate flag variable. If a particular application uses this pattern a lot, it can be simplified even further by means of a small helper class::
python, official-docs, cpython, P0
Local_Trusted_Corpus
3481da0f-4f6c-4a9b-b6d8-de5fbb841ffa
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,477
supabase-export-v2
bf361a6df0fbaa7a
it clear that the ``cm`` applies to the whole function, rather than just a piece of it (and saving an indentation level is nice, too). Existing context managers that already have a base class can be extended by using ``ContextDecorator`` as a mixin class::
trusted_official_docs
CPython Docs
it clear that the ``cm`` applies to the whole function, rather than just a piece of it (and saving an indentation level is nice, too). Existing context managers that already have a base class can be extended by using ``ContextDecorator`` as a mixin class::
it clear that the ``cm`` applies to the whole function, rather than just a piece of it (and saving an indentation level is nice, too). Existing context managers that already have a base class can be extended by using ``ContextDecorator`` as a mixin class::
python, official-docs, cpython, P0
Local_Trusted_Corpus
350f1e24-e928-4fbb-95fe-56654d0f5d5b
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,516
supabase-export-v2
f352fa0c5139bb28
As ``__enter__`` is *not* invoked, this method can be used to cover part of an :meth:`~object.__enter__` implementation with a context manager's own :meth:`~object.__exit__` method. If passed an object that is not a context manager, this method assumes it is a callback with the same signature as a context manager's :...
trusted_official_docs
CPython Docs
As ``__enter__`` is *not* invoked, this method can be used to cover part of an :meth:`~object.__enter__` implementation with a context manager's own :meth:`~object.__exit__` method. If passed an object that is not a context manager, this method assumes it is a callback with the same signature as a context manager's :...
As ``__enter__`` is *not* invoked, this method can be used to cover part of an :meth:`~object.__enter__` implementation with a context manager's own :meth:`~object.__exit__` method. If passed an object that is not a context manager, this method assumes it is a callback with the same signature as a context manager's :...
python, official-docs, cpython, P0
Local_Trusted_Corpus
352d702f-ec77-4b39-a254-bea26f53caeb
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,488
supabase-export-v2
452d70165bc2d0de
is entered and exited with :keyword:`async with`. Decorate coroutine functions and asynchronous generator functions with this class; the returned wrapper is of the same kind. .. note:: Synchronous functions and generators are accepted, but the wrapper is always asynchronous, so the decorated callable must then be awa...
trusted_official_docs
CPython Docs
is entered and exited with :keyword:`async with`. Decorate coroutine functions and asynchronous generator functions with this class; the returned wrapper is of the same kind. .. note:: Synchronous functions and generators are accepted, but the wrapper is always asynchronous, so the decorated callable must then be awa...
is entered and exited with :keyword:`async with`. Decorate coroutine functions and asynchronous generator functions with this class; the returned wrapper is of the same kind. .. note:: Synchronous functions and generators are accepted, but the wrapper is always asynchronous, so the decorated callable must then be awa...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3b13e87b-4ca6-4b31-bb76-dc35285810e2
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,385
supabase-export-v2
4363ef09f08dc871
Similar to :func:`~contextlib.contextmanager`, but creates an :ref:`asynchronous context manager <async-context-managers>`. This function is a :term:`decorator` that can be used to define a factory function for :keyword:`async with` statement asynchronous context managers, without needing to create a class or separat...
trusted_official_docs
CPython Docs
Similar to :func:`~contextlib.contextmanager`, but creates an :ref:`asynchronous context manager <async-context-managers>`. This function is a :term:`decorator` that can be used to define a factory function for :keyword:`async with` statement asynchronous context managers, without needing to create a class or separat...
Similar to :func:`~contextlib.contextmanager`, but creates an :ref:`asynchronous context manager <async-context-managers>`. This function is a :term:`decorator` that can be used to define a factory function for :keyword:`async with` statement asynchronous context managers, without needing to create a class or separat...
python, official-docs, cpython, P0
Local_Trusted_Corpus
40ac791d-d138-45c6-aad4-fbc341d3c48f
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,620
supabase-export-v2
8a66ce59d8549fae
Using separate :class:`ExitStack` instances instead of reusing a single instance avoids that problem:: >>> from contextlib import ExitStack >>> with ExitStack() as outer_stack: ... outer_stack.callback(print, "Callback: from outer context") ... with ExitStack() as inner_stack: ... inner_stack.callback(print, "Callb...
trusted_official_docs
CPython Docs
Using separate :class:`ExitStack` instances instead of reusing a single instance avoids that problem:: >>> from contextlib import ExitStack >>> with ExitStack() as outer_stack: ... outer_stack.callback(print, "Callback: from outer context") ... with ExitStack() as inner_stack: ... inner_stack.callback(print, "Callb...
Using separate :class:`ExitStack` instances instead of reusing a single instance avoids that problem:: >>> from contextlib import ExitStack >>> with ExitStack() as outer_stack: ... outer_stack.callback(print, "Callback: from outer context") ... with ExitStack() as inner_stack: ... inner_stack.callback(print, "Callb...
python, official-docs, cpython, P0
Local_Trusted_Corpus
46159777-b829-4cd5-9f7d-f61f7ae75992
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,487
supabase-export-v2
37a883b791b03dfc
.. class:: AsyncContextDecorator Similar to :class:`ContextDecorator`, but the context manager is entered and exited with :keyword:`async with`. Decorate coroutine functions and asynchronous generator functions with this class; the returned wrapper is of the same kind.
trusted_official_docs
CPython Docs
.. class:: AsyncContextDecorator Similar to :class:`ContextDecorator`, but the context manager is entered and exited with :keyword:`async with`. Decorate coroutine functions and asynchronous generator functions with this class; the returned wrapper is of the same kind.
.. class:: AsyncContextDecorator Similar to :class:`ContextDecorator`, but the context manager is entered and exited with :keyword:`async with`. Decorate coroutine functions and asynchronous generator functions with this class; the returned wrapper is of the same kind.
python, official-docs, cpython, P0
Local_Trusted_Corpus
4bb1d40f-cea5-4b2e-a85c-91ac68b45518
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,503
supabase-export-v2
9478b17ad47af856
The :meth:`~object.__enter__` method returns the :class:`ExitStack` instance, and performs no additional operations. Each instance maintains a stack of registered callbacks that are called in reverse order when the instance is closed (either explicitly or implicitly at the end of a :keyword:`with` statement). Note th...
trusted_official_docs
CPython Docs
The :meth:`~object.__enter__` method returns the :class:`ExitStack` instance, and performs no additional operations. Each instance maintains a stack of registered callbacks that are called in reverse order when the instance is closed (either explicitly or implicitly at the end of a :keyword:`with` statement). Note th...
The :meth:`~object.__enter__` method returns the :class:`ExitStack` instance, and performs no additional operations. Each instance maintains a stack of registered callbacks that are called in reverse order when the instance is closed (either explicitly or implicitly at the end of a :keyword:`with` statement). Note th...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4d276fc0-59f4-4464-bfb4-113421589f62
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,444
supabase-export-v2
2b07e2b4a82483f8
This tool adds flexibility to existing functions or classes whose output is hardwired to :data:`sys.stdout`. For example, the output of :func:`help` normally is sent to *sys.stdout*. You can capture that output in a string by redirecting the output to an :class:`io.StringIO` object. The replacement stream is returned ...
trusted_official_docs
CPython Docs
This tool adds flexibility to existing functions or classes whose output is hardwired to :data:`sys.stdout`. For example, the output of :func:`help` normally is sent to *sys.stdout*. You can capture that output in a string by redirecting the output to an :class:`io.StringIO` object. The replacement stream is returned ...
This tool adds flexibility to existing functions or classes whose output is hardwired to :data:`sys.stdout`. For example, the output of :func:`help` normally is sent to *sys.stdout*. You can capture that output in a string by redirecting the output to an :class:`io.StringIO` object. The replacement stream is returned ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4d3e6481-d106-4583-b1bb-c77a2cfedde1
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,604
supabase-export-v2
177ba4c890a3caec
single use context managers, and will complain about the underlying generator failing to yield if an attempt is made to use them a second time:: >>> from contextlib import contextmanager >>> @contextmanager ... def singleuse(): ... print("Before") ... yield ... print("After") ... >>> cm = singleuse() >>> with cm...
trusted_official_docs
CPython Docs
single use context managers, and will complain about the underlying generator failing to yield if an attempt is made to use them a second time:: >>> from contextlib import contextmanager >>> @contextmanager ... def singleuse(): ... print("Before") ... yield ... print("After") ... >>> cm = singleuse() >>> with cm...
single use context managers, and will complain about the underlying generator failing to yield if an attempt is made to use them a second time:: >>> from contextlib import contextmanager >>> @contextmanager ... def singleuse(): ... print("Before") ... yield ... print("After") ... >>> cm = singleuse() >>> with cm...
python, official-docs, cpython, P0
Local_Trusted_Corpus
567d9f43-8f79-48a9-a0e3-6d1d82cd25b5
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,611
supabase-export-v2
4d6b24b80d827a9a
Real world examples of reentrancy are more likely to involve multiple functions calling each other and hence be far more complicated than this example. Note also that being reentrant is *not* the same thing as being thread safe. :func:`redirect_stdout`, for example, is definitely not thread safe, as it makes a global m...
trusted_official_docs
CPython Docs
Real world examples of reentrancy are more likely to involve multiple functions calling each other and hence be far more complicated than this example. Note also that being reentrant is *not* the same thing as being thread safe. :func:`redirect_stdout`, for example, is definitely not thread safe, as it makes a global m...
Real world examples of reentrancy are more likely to involve multiple functions calling each other and hence be far more complicated than this example. Note also that being reentrant is *not* the same thing as being thread safe. :func:`redirect_stdout`, for example, is definitely not thread safe, as it makes a global m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
56c9ec9e-7e48-4995-ae73-ec81e064d275
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,619
supabase-export-v2
0e7921c2c960bbb1
to nest them will cause the stack to be cleared at the end of the innermost with statement, which is unlikely to be desirable behaviour. Using separate :class:`ExitStack` instances instead of reusing a single instance avoids that problem::
trusted_official_docs
CPython Docs
to nest them will cause the stack to be cleared at the end of the innermost with statement, which is unlikely to be desirable behaviour. Using separate :class:`ExitStack` instances instead of reusing a single instance avoids that problem::
to nest them will cause the stack to be cleared at the end of the innermost with statement, which is unlikely to be desirable behaviour. Using separate :class:`ExitStack` instances instead of reusing a single instance avoids that problem::
python, official-docs, cpython, P0
Local_Trusted_Corpus
579d017a-7f1a-4502-b606-6d283ccf708a
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,419
supabase-export-v2
b8937d7f667dcfae
that returns *enter_result* from :meth:`~object.__enter__`, but otherwise does nothing. It is intended to be used as a stand-in for an optional context manager, for example:: def myfunction(arg, ignore_exceptions=False): if ignore_exceptions: # Use suppress to ignore all exceptions. cm = contextlib.suppress(Exception...
trusted_official_docs
CPython Docs
that returns *enter_result* from :meth:`~object.__enter__`, but otherwise does nothing. It is intended to be used as a stand-in for an optional context manager, for example:: def myfunction(arg, ignore_exceptions=False): if ignore_exceptions: # Use suppress to ignore all exceptions. cm = contextlib.suppress(Exception...
that returns *enter_result* from :meth:`~object.__enter__`, but otherwise does nothing. It is intended to be used as a stand-in for an optional context manager, for example:: def myfunction(arg, ignore_exceptions=False): if ignore_exceptions: # Use suppress to ignore all exceptions. cm = contextlib.suppress(Exception...
python, official-docs, cpython, P0
Local_Trusted_Corpus
57f9f6b2-5cca-455e-bbb0-777121549857
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,584
supabase-export-v2
220e679d0cb44856
Using a context manager as a function decorator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :class:`ContextDecorator` makes it possible to use a context manager in both an ordinary ``with`` statement and also as a function decorator.
trusted_official_docs
CPython Docs
Using a context manager as a function decorator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :class:`ContextDecorator` makes it possible to use a context manager in both an ordinary ``with`` statement and also as a function decorator.
Using a context manager as a function decorator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :class:`ContextDecorator` makes it possible to use a context manager in both an ordinary ``with`` statement and also as a function decorator.
python, official-docs, cpython, P0
Local_Trusted_Corpus
5ceda6c9-ab35-45ad-969d-61ec6ea99f88
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,532
supabase-export-v2
b4ccd6c60bf425f5
An :ref:`asynchronous context manager <async-context-managers>`, similar to :class:`ExitStack`, that supports combining both synchronous and asynchronous context managers, as well as having coroutines for cleanup logic. The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must be used instead.
trusted_official_docs
CPython Docs
An :ref:`asynchronous context manager <async-context-managers>`, similar to :class:`ExitStack`, that supports combining both synchronous and asynchronous context managers, as well as having coroutines for cleanup logic. The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must be used instead.
An :ref:`asynchronous context manager <async-context-managers>`, similar to :class:`ExitStack`, that supports combining both synchronous and asynchronous context managers, as well as having coroutines for cleanup logic. The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must be used instead.
python, official-docs, cpython, P0
Local_Trusted_Corpus
5d7fe8f6-fdf2-45d2-abba-809320ab5b44
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,559
supabase-export-v2
8fe998d0b16dd8df
in the documentation of :meth:`ExitStack.push`, this method can be useful in cleaning up an already allocated resource if later steps in the :meth:`~object.__enter__` implementation fail. Here's an example of doing this for a context manager that accepts resource acquisition and release functions, along with an optiona...
trusted_official_docs
CPython Docs
in the documentation of :meth:`ExitStack.push`, this method can be useful in cleaning up an already allocated resource if later steps in the :meth:`~object.__enter__` implementation fail. Here's an example of doing this for a context manager that accepts resource acquisition and release functions, along with an optiona...
in the documentation of :meth:`ExitStack.push`, this method can be useful in cleaning up an already allocated resource if later steps in the :meth:`~object.__enter__` implementation fail. Here's an example of doing this for a context manager that accepts resource acquisition and release functions, along with an optiona...
python, official-docs, cpython, P0
Local_Trusted_Corpus
611bca3c-4cf4-47f6-b8c8-cda2746fd828
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,373
supabase-export-v2
ea6d2127f2458608
can be used to define a factory function for :keyword:`with` statement context managers, without needing to create a class or separate :meth:`~object.__enter__` and :meth:`~object.__exit__` methods. While many objects natively support use in with statements, sometimes a resource needs to be managed that isn't a contex...
trusted_official_docs
CPython Docs
can be used to define a factory function for :keyword:`with` statement context managers, without needing to create a class or separate :meth:`~object.__enter__` and :meth:`~object.__exit__` methods. While many objects natively support use in with statements, sometimes a resource needs to be managed that isn't a contex...
can be used to define a factory function for :keyword:`with` statement context managers, without needing to create a class or separate :meth:`~object.__enter__` and :meth:`~object.__exit__` methods. While many objects natively support use in with statements, sometimes a resource needs to be managed that isn't a contex...
python, official-docs, cpython, P0
Local_Trusted_Corpus
62225994-fc2d-4f18-8400-39b01cbd1c23
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,505
supabase-export-v2
53e62cd55cb50c0a
This stack model is used so that context managers that acquire their resources in their ``__init__`` method (such as file objects) can be handled correctly. Since registered callbacks are invoked in the reverse order of registration, this ends up behaving as if multiple nested :keyword:`with` statements had been used...
trusted_official_docs
CPython Docs
This stack model is used so that context managers that acquire their resources in their ``__init__`` method (such as file objects) can be handled correctly. Since registered callbacks are invoked in the reverse order of registration, this ends up behaving as if multiple nested :keyword:`with` statements had been used...
This stack model is used so that context managers that acquire their resources in their ``__init__`` method (such as file objects) can be handled correctly. Since registered callbacks are invoked in the reverse order of registration, this ends up behaving as if multiple nested :keyword:`with` statements had been used...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6485a764-74a1-4fbe-8ae6-057fe859bc03
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,560
supabase-export-v2
0e6bff3dcef7b9bb
for a context manager that accepts resource acquisition and release functions, along with an optional validation function, and maps them to the context management protocol:: from contextlib import contextmanager, AbstractContextManager, ExitStack
trusted_official_docs
CPython Docs
for a context manager that accepts resource acquisition and release functions, along with an optional validation function, and maps them to the context management protocol:: from contextlib import contextmanager, AbstractContextManager, ExitStack
for a context manager that accepts resource acquisition and release functions, along with an optional validation function, and maps them to the context management protocol:: from contextlib import contextmanager, AbstractContextManager, ExitStack
python, official-docs, cpython, P0
Local_Trusted_Corpus
64c29a9d-1dd2-4238-a94a-798248b8cbee
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,618
supabase-export-v2
b7bcac8d09374cf9
inner context") ... print("Leaving inner context") ... print("Leaving outer context") ... Leaving inner context Callback: from inner context Callback: from outer context Leaving outer context As the output from the example shows, reusing a single stack object across multiple with statements works correctly, but attempt...
trusted_official_docs
CPython Docs
inner context") ... print("Leaving inner context") ... print("Leaving outer context") ... Leaving inner context Callback: from inner context Callback: from outer context Leaving outer context As the output from the example shows, reusing a single stack object across multiple with statements works correctly, but attempt...
inner context") ... print("Leaving inner context") ... print("Leaving outer context") ... Leaving inner context Callback: from inner context Callback: from outer context Leaving outer context As the output from the example shows, reusing a single stack object across multiple with statements works correctly, but attempt...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6558b357-d73e-4f37-bdbb-1e0af392b5b1
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,614
supabase-export-v2
413971ee788bbed7
Reusable context managers ^^^^^^^^^^^^^^^^^^^^^^^^^ Distinct from both single use and reentrant context managers are "reusable" context managers (or, to be completely explicit, "reusable, but not reentrant" context managers, since reentrant context managers are also reusable). These context managers support being used ...
trusted_official_docs
CPython Docs
Reusable context managers ^^^^^^^^^^^^^^^^^^^^^^^^^ Distinct from both single use and reentrant context managers are "reusable" context managers (or, to be completely explicit, "reusable, but not reentrant" context managers, since reentrant context managers are also reusable). These context managers support being used ...
Reusable context managers ^^^^^^^^^^^^^^^^^^^^^^^^^ Distinct from both single use and reentrant context managers are "reusable" context managers (or, to be completely explicit, "reusable, but not reentrant" context managers, since reentrant context managers are also reusable). These context managers support being used ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
686d1357-3201-4c9a-84d4-6cecf2ff4d3b
CPython Docs
file://datasets/cpython/Doc/library/contextlib.rst
unknown
ffd60464-ed92-4f77-8236-03860b1deb46
28,602
supabase-export-v2
27ae5f525066f825
to create context managers directly in the header of the :keyword:`with` statement where they are used (as shown in all of the usage examples above). Files are an example of effectively single use context managers, since the first :keyword:`with` statement will close the file, preventing any further IO operations using...
trusted_official_docs
CPython Docs
to create context managers directly in the header of the :keyword:`with` statement where they are used (as shown in all of the usage examples above). Files are an example of effectively single use context managers, since the first :keyword:`with` statement will close the file, preventing any further IO operations using...
to create context managers directly in the header of the :keyword:`with` statement where they are used (as shown in all of the usage examples above). Files are an example of effectively single use context managers, since the first :keyword:`with` statement will close the file, preventing any further IO operations using...
python, official-docs, cpython, P0
Local_Trusted_Corpus