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
db12ba93-8aae-4481-a034-89a4bbb9916e
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,076
supabase-export-v2
804372eb6a6a8e02
.. option:: -p <interpreter>, --python=<interpreter> Add a ``#!`` line to the archive specifying *interpreter* as the command to run. Also, on POSIX, make the archive executable. The default is to write no ``#!`` line, and not make the file executable.
trusted_official_docs
CPython Docs
.. option:: -p <interpreter>, --python=<interpreter> Add a ``#!`` line to the archive specifying *interpreter* as the command to run. Also, on POSIX, make the archive executable. The default is to write no ``#!`` line, and not make the file executable.
.. option:: -p <interpreter>, --python=<interpreter> Add a ``#!`` line to the archive specifying *interpreter* as the command to run. Also, on POSIX, make the archive executable. The default is to write no ``#!`` line, and not make the file executable.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f0b63d8d-86ba-4a87-aa16-989cca9f1de3
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,132
supabase-export-v2
7ebfd65e2780fdbe
$ python -m zipapp -p "interpreter" myapp This will produce a standalone executable, which can be run on any machine with the appropriate interpreter available. See :ref:`zipapp-specifying-the-interpreter` for details. It can be shipped to users as a single file.
trusted_official_docs
CPython Docs
$ python -m zipapp -p "interpreter" myapp This will produce a standalone executable, which can be run on any machine with the appropriate interpreter available. See :ref:`zipapp-specifying-the-interpreter` for details. It can be shipped to users as a single file.
$ python -m zipapp -p "interpreter" myapp This will produce a standalone executable, which can be run on any machine with the appropriate interpreter available. See :ref:`zipapp-specifying-the-interpreter` for details. It can be shipped to users as a single file.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f6620732-5881-4f72-951e-5d16e9d46d65
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,120
supabase-export-v2
beaf7eec0d1bacf0
careful of using an exact version like "/usr/bin/env python3.4" as you will need to change your shebang line for users of Python 3.5, for example. Typically, you should use an "/usr/bin/env python2" or "/usr/bin/env python3", depending on whether your code is written for Python 2 or 3.
trusted_official_docs
CPython Docs
careful of using an exact version like "/usr/bin/env python3.4" as you will need to change your shebang line for users of Python 3.5, for example. Typically, you should use an "/usr/bin/env python2" or "/usr/bin/env python3", depending on whether your code is written for Python 2 or 3.
careful of using an exact version like "/usr/bin/env python3.4" as you will need to change your shebang line for users of Python 3.5, for example. Typically, you should use an "/usr/bin/env python2" or "/usr/bin/env python3", depending on whether your code is written for Python 2 or 3.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f6d047ca-7a3f-4611-a484-c0199cc380d6
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,069
supabase-export-v2
bbf0af13c465f4c5
$ python -m zipapp source [options] If *source* is a directory, this will create an archive from the contents of *source*. If *source* is a file, it should be an archive, and it will be copied to the target archive (or the contents of its shebang line will be displayed if the --info option is specified).
trusted_official_docs
CPython Docs
$ python -m zipapp source [options] If *source* is a directory, this will create an archive from the contents of *source*. If *source* is a file, it should be an archive, and it will be copied to the target archive (or the contents of its shebang line will be displayed if the --info option is specified).
$ python -m zipapp source [options] If *source* is a directory, this will create an archive from the contents of *source*. If *source* is a file, it should be an archive, and it will be copied to the target archive (or the contents of its shebang line will be displayed if the --info option is specified).
python, official-docs, cpython, P0
Local_Trusted_Corpus
f8098676-b680-49f5-be69-4ed3f70891e8
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,115
supabase-export-v2
d1c73b693b7c26a3
code does not protect against such errors, but production code should do so. Also, this method will only work if the archive fits in memory:: >>> import zipapp >>> import io >>> temp = io.BytesIO() >>> zipapp.create_archive('myapp.pyz', temp, '/usr/bin/python2') >>> with open('myapp.pyz', 'wb') as f: >>> f.write(t...
trusted_official_docs
CPython Docs
code does not protect against such errors, but production code should do so. Also, this method will only work if the archive fits in memory:: >>> import zipapp >>> import io >>> temp = io.BytesIO() >>> zipapp.create_archive('myapp.pyz', temp, '/usr/bin/python2') >>> with open('myapp.pyz', 'wb') as f: >>> f.write(t...
code does not protect against such errors, but production code should do so. Also, this method will only work if the archive fits in memory:: >>> import zipapp >>> import io >>> temp = io.BytesIO() >>> zipapp.create_archive('myapp.pyz', temp, '/usr/bin/python2') >>> with open('myapp.pyz', 'wb') as f: >>> f.write(t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f9c595e0-905b-4a96-bdf8-bd7edf0be6f2
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,141
supabase-export-v2
ae35cdb9135f9765
(which must be in the "root" of the zipfile - i.e., it cannot be in a subdirectory). The zipfile data can be compressed or uncompressed. If an application archive has a shebang line, it may have the executable bit set on POSIX systems, to allow it to be executed directly.
trusted_official_docs
CPython Docs
(which must be in the "root" of the zipfile - i.e., it cannot be in a subdirectory). The zipfile data can be compressed or uncompressed. If an application archive has a shebang line, it may have the executable bit set on POSIX systems, to allow it to be executed directly.
(which must be in the "root" of the zipfile - i.e., it cannot be in a subdirectory). The zipfile data can be compressed or uncompressed. If an application archive has a shebang line, it may have the executable bit set on POSIX systems, to allow it to be executed directly.
python, official-docs, cpython, P0
Local_Trusted_Corpus
fa29729a-d169-4df5-a89c-71369435c8ab
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,102
supabase-export-v2
2030be4eb7c0d30b
.. function:: get_interpreter(archive) Return the interpreter specified in the ``#!`` line at the start of the archive. If there is no ``#!`` line, return :const:`None`. The *archive* argument can be a filename or a file-like object open for reading in bytes mode. It is assumed to be at the start of the archive.
trusted_official_docs
CPython Docs
.. function:: get_interpreter(archive) Return the interpreter specified in the ``#!`` line at the start of the archive. If there is no ``#!`` line, return :const:`None`. The *archive* argument can be a filename or a file-like object open for reading in bytes mode. It is assumed to be at the start of the archive.
.. function:: get_interpreter(archive) Return the interpreter specified in the ``#!`` line at the start of the archive. If there is no ``#!`` line, return :const:`None`. The *archive* argument can be a filename or a file-like object open for reading in bytes mode. It is assumed to be at the start of the archive.
python, official-docs, cpython, P0
Local_Trusted_Corpus
fc9dc3a6-4068-4ec3-95de-5e27cef2b7c0
CPython Docs
file://datasets/cpython/Doc/library/zipapp.rst
unknown
7e6347e7-09be-496f-ac93-4481f8807e34
5,084
supabase-export-v2
ec50fd1c11e3223c
.. option:: --info Display the interpreter embedded in the archive, for diagnostic purposes. In this case, any other options are ignored and SOURCE must be an archive, not a directory.
trusted_official_docs
CPython Docs
.. option:: --info Display the interpreter embedded in the archive, for diagnostic purposes. In this case, any other options are ignored and SOURCE must be an archive, not a directory.
.. option:: --info Display the interpreter embedded in the archive, for diagnostic purposes. In this case, any other options are ignored and SOURCE must be an archive, not a directory.
python, official-docs, cpython, P0
Local_Trusted_Corpus
004bdda2-f11f-4771-bb85-3150e67d801e
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,169
supabase-export-v2
54f3fbf04324e1c2
If the class already defines :meth:`!__init__`, this parameter is ignored. - *repr*: If true (the default), a :meth:`~object.__repr__` method will be generated. The generated repr string will have the class name and the name and repr of each field, in the order they are defined in the class. Fields that are marked a...
trusted_official_docs
CPython Docs
If the class already defines :meth:`!__init__`, this parameter is ignored. - *repr*: If true (the default), a :meth:`~object.__repr__` method will be generated. The generated repr string will have the class name and the name and repr of each field, in the order they are defined in the class. Fields that are marked a...
If the class already defines :meth:`!__init__`, this parameter is ignored. - *repr*: If true (the default), a :meth:`~object.__repr__` method will be generated. The generated repr string will have the class name and the name and repr of each field, in the order they are defined in the class. Fields that are marked a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
039ac057-8709-485b-a40a-33a412ee3f0a
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,229
supabase-export-v2
fcc1eed34e63355d
.. function:: fields(class_or_instance) Returns a tuple of :class:`Field` objects that define the fields for this dataclass. Accepts either a dataclass, or an instance of a dataclass. Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does not return pseudo-fields which are ``ClassVar`` or ``InitVar...
trusted_official_docs
CPython Docs
.. function:: fields(class_or_instance) Returns a tuple of :class:`Field` objects that define the fields for this dataclass. Accepts either a dataclass, or an instance of a dataclass. Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does not return pseudo-fields which are ``ClassVar`` or ``InitVar...
.. function:: fields(class_or_instance) Returns a tuple of :class:`Field` objects that define the fields for this dataclass. Accepts either a dataclass, or an instance of a dataclass. Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does not return pseudo-fields which are ``ClassVar`` or ``InitVar...
python, official-docs, cpython, P0
Local_Trusted_Corpus
06384696-0f9b-4ca1-91fc-1dc2dc51380e
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,192
supabase-export-v2
591144bcb8b63ab5
names of a dataclass. Use :func:`fields` instead. To be able to determine inherited slots, base class :attr:`!__slots__` may be any iterable, but *not* an iterator. - *weakref_slot*: If true (the default is ``False``), add a slot named "__weakref__", which is required to make an instance :func:`weakref-able <weakref....
trusted_official_docs
CPython Docs
names of a dataclass. Use :func:`fields` instead. To be able to determine inherited slots, base class :attr:`!__slots__` may be any iterable, but *not* an iterator. - *weakref_slot*: If true (the default is ``False``), add a slot named "__weakref__", which is required to make an instance :func:`weakref-able <weakref....
names of a dataclass. Use :func:`fields` instead. To be able to determine inherited slots, base class :attr:`!__slots__` may be any iterable, but *not* an iterator. - *weakref_slot*: If true (the default is ``False``), add a slot named "__weakref__", which is required to make an instance :func:`weakref-able <weakref....
python, official-docs, cpython, P0
Local_Trusted_Corpus
0670bd02-dfbb-47c5-b7b4-7f1d4e72e2fc
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,290
supabase-export-v2
6e7379bb769b619a
def __post_init__(self): super().__init__(self.side, self.side) Note, however, that in general the dataclass-generated :meth:`!__init__` methods don't need to be called, since the derived dataclass will take care of initializing all fields of any base class that is a dataclass itself.
trusted_official_docs
CPython Docs
def __post_init__(self): super().__init__(self.side, self.side) Note, however, that in general the dataclass-generated :meth:`!__init__` methods don't need to be called, since the derived dataclass will take care of initializing all fields of any base class that is a dataclass itself.
def __post_init__(self): super().__init__(self.side, self.side) Note, however, that in general the dataclass-generated :meth:`!__init__` methods don't need to be called, since the derived dataclass will take care of initializing all fields of any base class that is a dataclass itself.
python, official-docs, cpython, P0
Local_Trusted_Corpus
09c5516d-ad7e-4df6-b050-64e939dfab1c
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,158
supabase-export-v2
3b543237a4354089
.. decorator:: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) This function is a :term:`decorator` that is used to add generated :term:`special methods <special method>` to classes, as described below.
trusted_official_docs
CPython Docs
.. decorator:: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) This function is a :term:`decorator` that is used to add generated :term:`special methods <special method>` to classes, as described below.
.. decorator:: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False) This function is a :term:`decorator` that is used to add generated :term:`special methods <special method>` to classes, as described below.
python, official-docs, cpython, P0
Local_Trusted_Corpus
0eaacfd4-184b-4c4f-baed-a971fc3ebc6f
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,207
supabase-export-v2
1897cb42d960b4a6
purposes, this can be used to specify fields with mutable default values, as discussed below. It is an error to specify both *default* and *default_factory*. - *init*: If true (the default), this field is included as a parameter to the generated :meth:`~object.__init__` method.
trusted_official_docs
CPython Docs
purposes, this can be used to specify fields with mutable default values, as discussed below. It is an error to specify both *default* and *default_factory*. - *init*: If true (the default), this field is included as a parameter to the generated :meth:`~object.__init__` method.
purposes, this can be used to specify fields with mutable default values, as discussed below. It is an error to specify both *default* and *default_factory*. - *init*: If true (the default), this field is included as a parameter to the generated :meth:`~object.__init__` method.
python, official-docs, cpython, P0
Local_Trusted_Corpus
15e7f51f-d62c-4cb0-8e36-93ba9603fefc
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,318
supabase-export-v2
e215bebba42eef27
to come after all regular (non-keyword-only) parameters. This is a requirement of how keyword-only parameters are implemented in Python: they must come after non-keyword-only parameters. In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are...
trusted_official_docs
CPython Docs
to come after all regular (non-keyword-only) parameters. This is a requirement of how keyword-only parameters are implemented in Python: they must come after non-keyword-only parameters. In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are...
to come after all regular (non-keyword-only) parameters. This is a requirement of how keyword-only parameters are implemented in Python: they must come after non-keyword-only parameters. In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are...
python, official-docs, cpython, P0
Local_Trusted_Corpus
18a33098-0ee2-4df8-8d4b-3a3f4e27ddeb
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,221
supabase-export-v2
e5339e3291fd9c43
The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` will not be set. .. versionchanged:: 3.15 If *metadata* is ``None``, use an empty :class:`frozendict`, instead of a :func:`~types.MappingProxyType` of an empty :clas...
trusted_official_docs
CPython Docs
The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` will not be set. .. versionchanged:: 3.15 If *metadata* is ``None``, use an empty :class:`frozendict`, instead of a :func:`~types.MappingProxyType` of an empty :clas...
The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` will not be set. .. versionchanged:: 3.15 If *metadata* is ``None``, use an empty :class:`frozendict`, instead of a :func:`~types.MappingProxyType` of an empty :clas...
python, official-docs, cpython, P0
Local_Trusted_Corpus
1c638c88-754e-483e-8bd2-e791ab884995
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,176
supabase-export-v2
4ba4aa611d101603
may not be safe to do so. Otherwise, generate a :meth:`~object.__hash__` method according to how *eq* and *frozen* are set. The default value is ``False``. :meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are added to hashed collections such as dictionaries and sets. Having a :meth:`!__hash__` imp...
trusted_official_docs
CPython Docs
may not be safe to do so. Otherwise, generate a :meth:`~object.__hash__` method according to how *eq* and *frozen* are set. The default value is ``False``. :meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are added to hashed collections such as dictionaries and sets. Having a :meth:`!__hash__` imp...
may not be safe to do so. Otherwise, generate a :meth:`~object.__hash__` method according to how *eq* and *frozen* are set. The default value is ``False``. :meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are added to hashed collections such as dictionaries and sets. Having a :meth:`!__hash__` imp...
python, official-docs, cpython, P0
Local_Trusted_Corpus
1f31a350-4160-4831-8efb-af4323861c73
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,209
supabase-export-v2
b0ccf1973e0c1b8d
- *repr*: If true (the default), this field is included in the string returned by the generated :meth:`~object.__repr__` method. - *hash*: This can be a bool or ``None``. If true, this field is included in the generated :meth:`~object.__hash__` method. If false, this field is excluded from the generated :meth:`~objec...
trusted_official_docs
CPython Docs
- *repr*: If true (the default), this field is included in the string returned by the generated :meth:`~object.__repr__` method. - *hash*: This can be a bool or ``None``. If true, this field is included in the generated :meth:`~object.__hash__` method. If false, this field is excluded from the generated :meth:`~objec...
- *repr*: If true (the default), this field is included in the string returned by the generated :meth:`~object.__repr__` method. - *hash*: This can be a bool or ``None``. If true, this field is included in the generated :meth:`~object.__hash__` method. If false, this field is excluded from the generated :meth:`~objec...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2127e871-5766-42c7-be03-a2c5fda5ae6c
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,199
supabase-export-v2
e2b05afa307a6174
value follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance. .. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING, doc=None)
trusted_official_docs
CPython Docs
value follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance. .. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING, doc=None)
value follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance. .. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING, doc=None)
python, official-docs, cpython, P0
Local_Trusted_Corpus
2a47ac73-7fcd-4968-9c88-c823ea6525e7
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,310
supabase-export-v2
092c36abbe4243eb
Inheritance ----------- When the dataclass is being created by the :deco:`dataclass` decorator, it looks through all of the class's base classes in reverse MRO (that is, starting at :class:`object`) and, for each dataclass that it finds, adds the fields from that base class to an ordered mapping of fields. After all of...
trusted_official_docs
CPython Docs
Inheritance ----------- When the dataclass is being created by the :deco:`dataclass` decorator, it looks through all of the class's base classes in reverse MRO (that is, starting at :class:`object`) and, for each dataclass that it finds, adds the fields from that base class to an ordered mapping of fields. After all of...
Inheritance ----------- When the dataclass is being created by the :deco:`dataclass` decorator, it looks through all of the class's base classes in reverse MRO (that is, starting at :class:`object`) and, for each dataclass that it finds, adds the fields from that base class to an ordered mapping of fields. After all of...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2b8d01b2-6dcb-4eb5-b0c9-67c5a3610480
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,225
supabase-export-v2
51442101a47e7295
the field. - :attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!kw_only` have the identical meaning and values as they do in the :func:`field` function. Other attributes may exist, but they are private and must not be inspected or r...
trusted_official_docs
CPython Docs
the field. - :attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!kw_only` have the identical meaning and values as they do in the :func:`field` function. Other attributes may exist, but they are private and must not be inspected or r...
the field. - :attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!kw_only` have the identical meaning and values as they do in the :func:`field` function. Other attributes may exist, but they are private and must not be inspected or r...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2cb6dfe3-80d8-477b-8885-2ab3d04e8b4f
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,198
supabase-export-v2
90594917fce143f6
def __init__(self, a: int, b: int = 0): :exc:`TypeError` will be raised if a field without a default value follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance.
trusted_official_docs
CPython Docs
def __init__(self, a: int, b: int = 0): :exc:`TypeError` will be raised if a field without a default value follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance.
def __init__(self, a: int, b: int = 0): :exc:`TypeError` will be raised if a field without a default value follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance.
python, official-docs, cpython, P0
Local_Trusted_Corpus
2d7df0c6-69c0-42a5-9d93-b67dee851296
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,267
supabase-export-v2
276c24d633b497e6
to know if a class is an instance of a dataclass (and not a dataclass itself), then add a further check for ``not isinstance(obj, type)``:: def is_dataclass_instance(obj): return is_dataclass(obj) and not isinstance(obj, type)
trusted_official_docs
CPython Docs
to know if a class is an instance of a dataclass (and not a dataclass itself), then add a further check for ``not isinstance(obj, type)``:: def is_dataclass_instance(obj): return is_dataclass(obj) and not isinstance(obj, type)
to know if a class is an instance of a dataclass (and not a dataclass itself), then add a further check for ``not isinstance(obj, type)``:: def is_dataclass_instance(obj): return is_dataclass(obj) and not isinstance(obj, type)
python, official-docs, cpython, P0
Local_Trusted_Corpus
33a112e1-9ff3-40cc-aca0-85f2f9065e33
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,319
supabase-export-v2
33d7199b802b386b
In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular fields:: @dataclass class Base: x: Any = 15.0 _: KW_ONLY y: int = 0 w: int = 1
trusted_official_docs
CPython Docs
In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular fields:: @dataclass class Base: x: Any = 15.0 _: KW_ONLY y: int = 0 w: int = 1
In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular fields:: @dataclass class Base: x: Any = 15.0 _: KW_ONLY y: int = 0 w: int = 1
python, official-docs, cpython, P0
Local_Trusted_Corpus
371d678f-4bd4-47a9-928e-2eb7f4a208f8
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,297
supabase-export-v2
8595118dd636e600
Init-only variables ------------------- Another place where :deco:`dataclass` inspects a type annotation is to determine if a field is an init-only variable. It does this by seeing if the type of a field is of type :class:`InitVar`. If a field is an :class:`InitVar`, it is considered a pseudo-field called an init-only ...
trusted_official_docs
CPython Docs
Init-only variables ------------------- Another place where :deco:`dataclass` inspects a type annotation is to determine if a field is an init-only variable. It does this by seeing if the type of a field is of type :class:`InitVar`. If a field is an :class:`InitVar`, it is considered a pseudo-field called an init-only ...
Init-only variables ------------------- Another place where :deco:`dataclass` inspects a type annotation is to determine if a field is an init-only variable. It does this by seeing if the type of a field is of type :class:`InitVar`. If a field is an :class:`InitVar`, it is considered a pseudo-field called an init-only ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3957c4aa-bd05-449f-801d-d9205ba396f5
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,186
supabase-export-v2
c80dd5a762a3b7e3
a keyword-only field must be specified with a keyword when :meth:`!__init__` is called. See the :term:`parameter` glossary entry for details. Also see the :const:`KW_ONLY` section. Keyword-only fields are not included in :attr:`!__match_args__`.
trusted_official_docs
CPython Docs
a keyword-only field must be specified with a keyword when :meth:`!__init__` is called. See the :term:`parameter` glossary entry for details. Also see the :const:`KW_ONLY` section. Keyword-only fields are not included in :attr:`!__match_args__`.
a keyword-only field must be specified with a keyword when :meth:`!__init__` is called. See the :term:`parameter` glossary entry for details. Also see the :const:`KW_ONLY` section. Keyword-only fields are not included in :attr:`!__match_args__`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
3baab4a7-a1fa-459a-b98a-8ece7e567bac
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,208
supabase-export-v2
927616b603f3a1ba
- *init*: If true (the default), this field is included as a parameter to the generated :meth:`~object.__init__` method. - *repr*: If true (the default), this field is included in the string returned by the generated :meth:`~object.__repr__` method.
trusted_official_docs
CPython Docs
- *init*: If true (the default), this field is included as a parameter to the generated :meth:`~object.__init__` method. - *repr*: If true (the default), this field is included in the string returned by the generated :meth:`~object.__repr__` method.
- *init*: If true (the default), this field is included as a parameter to the generated :meth:`~object.__init__` method. - *repr*: If true (the default), this field is included in the string returned by the generated :meth:`~object.__repr__` method.
python, official-docs, cpython, P0
Local_Trusted_Corpus
3d94ed26-47a8-4b8c-ad62-02cc7591588d
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,210
supabase-export-v2
65954198ea8cb10f
behavior, since a field should be included in the hash if it's used for comparisons. Setting this value to anything other than ``None`` is discouraged. One possible reason to set ``hash=False`` but ``compare=True`` would be if a field is expensive to compute a hash value for, that field is needed for equality testing...
trusted_official_docs
CPython Docs
behavior, since a field should be included in the hash if it's used for comparisons. Setting this value to anything other than ``None`` is discouraged. One possible reason to set ``hash=False`` but ``compare=True`` would be if a field is expensive to compute a hash value for, that field is needed for equality testing...
behavior, since a field should be included in the hash if it's used for comparisons. Setting this value to anything other than ``None`` is discouraged. One possible reason to set ``hash=False`` but ``compare=True`` would be if a field is expensive to compute a hash value for, that field is needed for equality testing...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3ff75c94-768d-4c97-8a7d-4915d1409cf8
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,260
supabase-export-v2
4b25ac121cbfc019
The newly returned object is created by calling the :meth:`~object.__init__` method of the dataclass. This ensures that :meth:`__post_init__`, if present, is also called. Init-only variables without default values, if any exist, must be specified on the call to :func:`!replace` so that they can be passed to :meth:`!_...
trusted_official_docs
CPython Docs
The newly returned object is created by calling the :meth:`~object.__init__` method of the dataclass. This ensures that :meth:`__post_init__`, if present, is also called. Init-only variables without default values, if any exist, must be specified on the call to :func:`!replace` so that they can be passed to :meth:`!_...
The newly returned object is created by calling the :meth:`~object.__init__` method of the dataclass. This ensures that :meth:`__post_init__`, if present, is also called. Init-only variables without default values, if any exist, must be specified on the call to :func:`!replace` so that they can be passed to :meth:`!_...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3ff86c00-1949-47a1-a0bd-e0a068fded26
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,250
supabase-export-v2
7b7c2df07a26c987
is defined, the :attr:`!__module__` attribute of the dataclass is set to that value. By default, it is set to the module name of the caller. The *decorator* parameter is a callable that will be used to create the dataclass. It should take the class object as a first argument and the same keyword arguments as :deco:`da...
trusted_official_docs
CPython Docs
is defined, the :attr:`!__module__` attribute of the dataclass is set to that value. By default, it is set to the module name of the caller. The *decorator* parameter is a callable that will be used to create the dataclass. It should take the class object as a first argument and the same keyword arguments as :deco:`da...
is defined, the :attr:`!__module__` attribute of the dataclass is set to that value. By default, it is set to the module name of the caller. The *decorator* parameter is a callable that will be used to create the dataclass. It should take the class object as a first argument and the same keyword arguments as :deco:`da...
python, official-docs, cpython, P0
Local_Trusted_Corpus
44f663f1-9032-4454-8dd0-22496af0fbe0
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,224
supabase-export-v2
32b73abadb59aa53
are created internally, and are returned by the :func:`fields` module-level method (see below). Users should never instantiate a :class:`!Field` object directly. Its documented attributes are: - :attr:`!name`: The name of the field. - :attr:`!type`: The type of the field. - :attr:`!default`, :attr:`!default_factory`, :...
trusted_official_docs
CPython Docs
are created internally, and are returned by the :func:`fields` module-level method (see below). Users should never instantiate a :class:`!Field` object directly. Its documented attributes are: - :attr:`!name`: The name of the field. - :attr:`!type`: The type of the field. - :attr:`!default`, :attr:`!default_factory`, :...
are created internally, and are returned by the :func:`fields` module-level method (see below). Users should never instantiate a :class:`!Field` object directly. Its documented attributes are: - :attr:`!name`: The name of the field. - :attr:`!type`: The type of the field. - :attr:`!default`, :attr:`!default_factory`, :...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4555f12e-3f02-49f5-bb9d-39041c86d9e8
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,231
supabase-export-v2
4e9f5a3e9e9ff951
.. function:: asdict(obj, *, dict_factory=dict) Converts the dataclass *obj* to a dict (by using the factory function *dict_factory*). Each dataclass is converted to a dict of its fields, as ``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :f...
trusted_official_docs
CPython Docs
.. function:: asdict(obj, *, dict_factory=dict) Converts the dataclass *obj* to a dict (by using the factory function *dict_factory*). Each dataclass is converted to a dict of its fields, as ``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :f...
.. function:: asdict(obj, *, dict_factory=dict) Converts the dataclass *obj* to a dict (by using the factory function *dict_factory*). Each dataclass is converted to a dict of its fields, as ``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :f...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4615331b-ec53-40df-b27d-41b349dedf77
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,284
supabase-export-v2
6b3e993329492bec
Among other uses, this allows for initializing field values that depend on one or more other fields. For example:: @dataclass class C: a: float b: float c: float = field(init=False)
trusted_official_docs
CPython Docs
Among other uses, this allows for initializing field values that depend on one or more other fields. For example:: @dataclass class C: a: float b: float c: float = field(init=False)
Among other uses, this allows for initializing field values that depend on one or more other fields. For example:: @dataclass class C: a: float b: float c: float = field(init=False)
python, official-docs, cpython, P0
Local_Trusted_Corpus
47422369-9abc-4e4a-8150-a0cd7e4eec2f
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,212
supabase-export-v2
c0482f5d5d7a2ec9
- *compare*: If true (the default), this field is included in the generated equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object.__gt__`, et al.). - *metadata*: This can be a mapping or ``None``. ``None`` is treated as an empty dict. This value is wrapped in :func:`~types.MappingProxyType` to make ...
trusted_official_docs
CPython Docs
- *compare*: If true (the default), this field is included in the generated equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object.__gt__`, et al.). - *metadata*: This can be a mapping or ``None``. ``None`` is treated as an empty dict. This value is wrapped in :func:`~types.MappingProxyType` to make ...
- *compare*: If true (the default), this field is included in the generated equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object.__gt__`, et al.). - *metadata*: This can be a mapping or ``None``. ``None`` is treated as an empty dict. This value is wrapped in :func:`~types.MappingProxyType` to make ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4a1c8722-4183-4dde-85f1-1559a85e9f1b
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,248
supabase-export-v2
523761828329bc21
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False, module=None, decorator=dataclass) Creates a new dataclass with name *cls_name*, fields as defined in ...
trusted_official_docs
CPython Docs
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False, module=None, decorator=dataclass) Creates a new dataclass with name *cls_name*, fields as defined in ...
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False, module=None, decorator=dataclass) Creates a new dataclass with name *cls_name*, fields as defined in ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4adaa59c-8232-4ad5-b8ab-0cc969e36532
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,147
supabase-export-v2
f6d9efa53311f169
-------------- This module provides a decorator and functions for automatically adding generated :term:`special methods <special method>` such as :meth:`~object.__init__` and :meth:`~object.__repr__` to user-defined classes. It was originally described in :pep:`557`.
trusted_official_docs
CPython Docs
-------------- This module provides a decorator and functions for automatically adding generated :term:`special methods <special method>` such as :meth:`~object.__init__` and :meth:`~object.__repr__` to user-defined classes. It was originally described in :pep:`557`.
-------------- This module provides a decorator and functions for automatically adding generated :term:`special methods <special method>` such as :meth:`~object.__init__` and :meth:`~object.__repr__` to user-defined classes. It was originally described in :pep:`557`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
4d67abaa-6431-4f05-877d-7a037118769e
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,200
supabase-export-v2
c9f36fb26db9018d
.. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING, doc=None) For common and simple use cases, no other functionality is required. There are, however, some dataclass features that require additional per-field information. To s...
trusted_official_docs
CPython Docs
.. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING, doc=None) For common and simple use cases, no other functionality is required. There are, however, some dataclass features that require additional per-field information. To s...
.. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING, doc=None) For common and simple use cases, no other functionality is required. There are, however, some dataclass features that require additional per-field information. To s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4fabcca0-dc06-41da-a254-4467be9403c4
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,213
supabase-export-v2
16f5723407f73d58
Classes, and is provided as a third-party extension mechanism. Multiple third-parties can each have their own key, to use as a namespace in the metadata. - *kw_only*: If true, this field will be marked as keyword-only. This is used when the generated :meth:`~object.__init__` method's parameters are computed.
trusted_official_docs
CPython Docs
Classes, and is provided as a third-party extension mechanism. Multiple third-parties can each have their own key, to use as a namespace in the metadata. - *kw_only*: If true, this field will be marked as keyword-only. This is used when the generated :meth:`~object.__init__` method's parameters are computed.
Classes, and is provided as a third-party extension mechanism. Multiple third-parties can each have their own key, to use as a namespace in the metadata. - *kw_only*: If true, this field will be marked as keyword-only. This is used when the generated :meth:`~object.__init__` method's parameters are computed.
python, official-docs, cpython, P0
Local_Trusted_Corpus
50b8eb12-031d-49da-abe7-ddfa2664a428
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,161
supabase-export-v2
9dc59411d5e2e7c7
The order of the fields in all of the generated methods is the order in which they appear in the class definition. The ``@dataclass`` decorator will add various "dunder" methods to the class, described below. If any of the added methods already exist in the class, the behavior depends on the parameter, as documented ...
trusted_official_docs
CPython Docs
The order of the fields in all of the generated methods is the order in which they appear in the class definition. The ``@dataclass`` decorator will add various "dunder" methods to the class, described below. If any of the added methods already exist in the class, the behavior depends on the parameter, as documented ...
The order of the fields in all of the generated methods is the order in which they appear in the class definition. The ``@dataclass`` decorator will add various "dunder" methods to the class, described below. If any of the added methods already exist in the class, the behavior depends on the parameter, as documented ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5194a3a2-cb2c-43d0-8d9c-969e54a2bcf0
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,252
supabase-export-v2
beed0d3ceb4da1c4
class with :attr:`~object.__annotations__` can then apply the :deco:`dataclass` function to convert that class to a dataclass. This function is provided as a convenience. For example:: C = make_dataclass('C', [('x', int), 'y', ('z', int, field(default=5))], namespace={'add_one': lambda self: self.x + 1})
trusted_official_docs
CPython Docs
class with :attr:`~object.__annotations__` can then apply the :deco:`dataclass` function to convert that class to a dataclass. This function is provided as a convenience. For example:: C = make_dataclass('C', [('x', int), 'y', ('z', int, field(default=5))], namespace={'add_one': lambda self: self.x + 1})
class with :attr:`~object.__annotations__` can then apply the :deco:`dataclass` function to convert that class to a dataclass. This function is provided as a convenience. For example:: C = make_dataclass('C', [('x', int), 'y', ('z', int, field(default=5))], namespace={'add_one': lambda self: self.x + 1})
python, official-docs, cpython, P0
Local_Trusted_Corpus
544ac4fa-abf9-42e8-b25b-262e9d3bf5b7
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,311
supabase-export-v2
b7ea03e4d348e594
generated methods will use this combined, calculated ordered mapping of fields. Because the fields are in insertion order, derived classes override base classes. An example:: @dataclass class Base: x: Any = 15.0 y: int = 0
trusted_official_docs
CPython Docs
generated methods will use this combined, calculated ordered mapping of fields. Because the fields are in insertion order, derived classes override base classes. An example:: @dataclass class Base: x: Any = 15.0 y: int = 0
generated methods will use this combined, calculated ordered mapping of fields. Because the fields are in insertion order, derived classes override base classes. An example:: @dataclass class Base: x: Any = 15.0 y: int = 0
python, official-docs, cpython, P0
Local_Trusted_Corpus
54f14f3b-8414-421b-ac35-66e9265357fe
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,182
supabase-export-v2
d2bd698d78f948cd
- *frozen*: If true (the default is ``False``), assigning to fields will generate an exception. This emulates read-only frozen instances. See the :ref:`discussion <dataclasses-frozen>` below. If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class and *frozen* is true, then :exc:`TypeErro...
trusted_official_docs
CPython Docs
- *frozen*: If true (the default is ``False``), assigning to fields will generate an exception. This emulates read-only frozen instances. See the :ref:`discussion <dataclasses-frozen>` below. If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class and *frozen* is true, then :exc:`TypeErro...
- *frozen*: If true (the default is ``False``), assigning to fields will generate an exception. This emulates read-only frozen instances. See the :ref:`discussion <dataclasses-frozen>` below. If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class and *frozen* is true, then :exc:`TypeErro...
python, official-docs, cpython, P0
Local_Trusted_Corpus
57b68488-4dfc-47a3-8cda-6d4c38cda751
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,241
supabase-export-v2
92b261ccb5ff59e5
.. function:: astuple(obj, *, tuple_factory=tuple) Converts the dataclass *obj* to a tuple (by using the factory function *tuple_factory*). Each dataclass is converted to a tuple of its field values. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deep...
trusted_official_docs
CPython Docs
.. function:: astuple(obj, *, tuple_factory=tuple) Converts the dataclass *obj* to a tuple (by using the factory function *tuple_factory*). Each dataclass is converted to a tuple of its field values. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deep...
.. function:: astuple(obj, *, tuple_factory=tuple) Converts the dataclass *obj* to a tuple (by using the factory function *tuple_factory*). Each dataclass is converted to a tuple of its field values. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deep...
python, official-docs, cpython, P0
Local_Trusted_Corpus
590dc3ac-3c5b-4ee6-a100-9755a64c4d6b
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,317
supabase-export-v2
820ae0dbe912a49c
Re-ordering of keyword-only parameters in :meth:`!__init__` ----------------------------------------------------------- After the parameters needed for :meth:`~object.__init__` are computed, any keyword-only parameters are moved to come after all regular (non-keyword-only) parameters. This is a requirement of how keywo...
trusted_official_docs
CPython Docs
Re-ordering of keyword-only parameters in :meth:`!__init__` ----------------------------------------------------------- After the parameters needed for :meth:`~object.__init__` are computed, any keyword-only parameters are moved to come after all regular (non-keyword-only) parameters. This is a requirement of how keywo...
Re-ordering of keyword-only parameters in :meth:`!__init__` ----------------------------------------------------------- After the parameters needed for :meth:`~object.__init__` are computed, any keyword-only parameters are moved to come after all regular (non-keyword-only) parameters. This is a requirement of how keywo...
python, official-docs, cpython, P0
Local_Trusted_Corpus
596afd88-bf81-40ce-95d3-54f4420336ed
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,162
supabase-export-v2
c405ee1e8f0e8423
the behavior depends on the parameter, as documented below. The decorator returns the same class that it is called on; no new class is created. If ``@dataclass`` is used just as a simple decorator with no parameters, it acts as if it has the default values documented in this signature. That is, these three uses of ``...
trusted_official_docs
CPython Docs
the behavior depends on the parameter, as documented below. The decorator returns the same class that it is called on; no new class is created. If ``@dataclass`` is used just as a simple decorator with no parameters, it acts as if it has the default values documented in this signature. That is, these three uses of ``...
the behavior depends on the parameter, as documented below. The decorator returns the same class that it is called on; no new class is created. If ``@dataclass`` is used just as a simple decorator with no parameters, it acts as if it has the default values documented in this signature. That is, these three uses of ``...
python, official-docs, cpython, P0
Local_Trusted_Corpus
59bb0c68-421e-43ae-b337-c1f8b1fbf230
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,307
supabase-export-v2
da788d070a1d6980
There is a tiny performance penalty when using ``frozen=True``: :meth:`~object.__init__` cannot use simple assignment to initialize fields, and must use :meth:`!object.__setattr__`. .. Make sure to not remove "object" from "object.__setattr__" in the above markup!
trusted_official_docs
CPython Docs
There is a tiny performance penalty when using ``frozen=True``: :meth:`~object.__init__` cannot use simple assignment to initialize fields, and must use :meth:`!object.__setattr__`. .. Make sure to not remove "object" from "object.__setattr__" in the above markup!
There is a tiny performance penalty when using ``frozen=True``: :meth:`~object.__init__` cannot use simple assignment to initialize fields, and must use :meth:`!object.__setattr__`. .. Make sure to not remove "object" from "object.__setattr__" in the above markup!
python, official-docs, cpython, P0
Local_Trusted_Corpus
5aac87a9-c262-4ef7-826f-810f87715197
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,251
supabase-export-v2
4ac037d899d9f4d7
dataclass. It should take the class object as a first argument and the same keyword arguments as :deco:`dataclass`. By default, the :deco:`dataclass` function is used. This function is not strictly required, because any Python mechanism for creating a new class with :attr:`~object.__annotations__` can then apply the ...
trusted_official_docs
CPython Docs
dataclass. It should take the class object as a first argument and the same keyword arguments as :deco:`dataclass`. By default, the :deco:`dataclass` function is used. This function is not strictly required, because any Python mechanism for creating a new class with :attr:`~object.__annotations__` can then apply the ...
dataclass. It should take the class object as a first argument and the same keyword arguments as :deco:`dataclass`. By default, the :deco:`dataclass` function is used. This function is not strictly required, because any Python mechanism for creating a new class with :attr:`~object.__annotations__` can then apply the ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5b7e0678-6f55-4d2f-aa5b-55e4d768a3b3
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,249
supabase-export-v2
4c9c90de64d5ec61
for ``type``. The values of *init*, *repr*, *eq*, *order*, *unsafe_hash*, *frozen*, *match_args*, *kw_only*, *slots*, and *weakref_slot* have the same meaning as they do in :deco:`dataclass`. If *module* is defined, the :attr:`!__module__` attribute of the dataclass is set to that value. By default, it is set to the m...
trusted_official_docs
CPython Docs
for ``type``. The values of *init*, *repr*, *eq*, *order*, *unsafe_hash*, *frozen*, *match_args*, *kw_only*, *slots*, and *weakref_slot* have the same meaning as they do in :deco:`dataclass`. If *module* is defined, the :attr:`!__module__` attribute of the dataclass is set to that value. By default, it is set to the m...
for ``type``. The values of *init*, *repr*, *eq*, *order*, *unsafe_hash*, *frozen*, *match_args*, *kw_only*, *slots*, and *weakref_slot* have the same meaning as they do in :deco:`dataclass`. If *module* is defined, the :attr:`!__module__` attribute of the dataclass is set to that value. By default, it is set to the m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5c02ac50-04c3-4743-8943-f5f66ee3fad1
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,185
supabase-export-v2
7a22ceedd308723e
.. versionadded:: 3.10 - *kw_only*: If true (the default value is ``False``), then all fields will be marked as keyword-only. If a field is marked as keyword-only, then the only effect is that the :meth:`~object.__init__` parameter generated from a keyword-only field must be specified with a keyword when :meth:`!__...
trusted_official_docs
CPython Docs
.. versionadded:: 3.10 - *kw_only*: If true (the default value is ``False``), then all fields will be marked as keyword-only. If a field is marked as keyword-only, then the only effect is that the :meth:`~object.__init__` parameter generated from a keyword-only field must be specified with a keyword when :meth:`!__...
.. versionadded:: 3.10 - *kw_only*: If true (the default value is ``False``), then all fields will be marked as keyword-only. If a field is marked as keyword-only, then the only effect is that the :meth:`~object.__init__` parameter generated from a keyword-only field must be specified with a keyword when :meth:`!__...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5efd4a1e-1fc2-4b34-8fb2-00c10717737b
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,154
supabase-export-v2
cd3bd1aab8e9421f
def __init__(self, name: str, unit_price: float, quantity_on_hand: int = 0): self.name = name self.unit_price = unit_price self.quantity_on_hand = quantity_on_hand Note that this method is automatically added to the class: it is not directly specified in the :class:`!InventoryItem` definition shown above.
trusted_official_docs
CPython Docs
def __init__(self, name: str, unit_price: float, quantity_on_hand: int = 0): self.name = name self.unit_price = unit_price self.quantity_on_hand = quantity_on_hand Note that this method is automatically added to the class: it is not directly specified in the :class:`!InventoryItem` definition shown above.
def __init__(self, name: str, unit_price: float, quantity_on_hand: int = 0): self.name = name self.unit_price = unit_price self.quantity_on_hand = quantity_on_hand Note that this method is automatically added to the class: it is not directly specified in the :class:`!InventoryItem` definition shown above.
python, official-docs, cpython, P0
Local_Trusted_Corpus
60d2aa7b-2c22-4e2e-b69c-7d946446e8c8
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,204
supabase-export-v2
464606d3c4877704
This sentinel is used because ``None`` is a valid value for some parameters with a distinct meaning. No code should directly use the :const:`MISSING` value. The parameters to :func:`!field` are:
trusted_official_docs
CPython Docs
This sentinel is used because ``None`` is a valid value for some parameters with a distinct meaning. No code should directly use the :const:`MISSING` value. The parameters to :func:`!field` are:
This sentinel is used because ``None`` is a valid value for some parameters with a distinct meaning. No code should directly use the :const:`MISSING` value. The parameters to :func:`!field` are:
python, official-docs, cpython, P0
Local_Trusted_Corpus
617ad0d8-5132-4281-bb40-f725b35a660b
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,261
supabase-export-v2
5023f30eb63586c7
variables without default values, if any exist, must be specified on the call to :func:`!replace` so that they can be passed to :meth:`!__init__` and :meth:`__post_init__`. It is an error for *changes* to contain any fields that are defined as having ``init=False``. A :exc:`ValueError` will be raised in this case.
trusted_official_docs
CPython Docs
variables without default values, if any exist, must be specified on the call to :func:`!replace` so that they can be passed to :meth:`!__init__` and :meth:`__post_init__`. It is an error for *changes* to contain any fields that are defined as having ``init=False``. A :exc:`ValueError` will be raised in this case.
variables without default values, if any exist, must be specified on the call to :func:`!replace` so that they can be passed to :meth:`!__init__` and :meth:`__post_init__`. It is an error for *changes* to contain any fields that are defined as having ``init=False``. A :exc:`ValueError` will be raised in this case.
python, official-docs, cpython, P0
Local_Trusted_Corpus
61c62ab1-e87b-41d2-9190-31a8f86ce91c
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,211
supabase-export-v2
f7551ec9db0d3c87
other fields that contribute to the type's hash value. Even if a field is excluded from the hash, it will still be used for comparisons. - *compare*: If true (the default), this field is included in the generated equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object.__gt__`, et al.).
trusted_official_docs
CPython Docs
other fields that contribute to the type's hash value. Even if a field is excluded from the hash, it will still be used for comparisons. - *compare*: If true (the default), this field is included in the generated equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object.__gt__`, et al.).
other fields that contribute to the type's hash value. Even if a field is excluded from the hash, it will still be used for comparisons. - *compare*: If true (the default), this field is included in the generated equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object.__gt__`, et al.).
python, official-docs, cpython, P0
Local_Trusted_Corpus
641f8bf8-db0f-4ae3-bb4e-a8078476f5b4
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,214
supabase-export-v2
672883f2e578bcba
- *kw_only*: If true, this field will be marked as keyword-only. This is used when the generated :meth:`~object.__init__` method's parameters are computed. Keyword-only fields are also not included in :attr:`!__match_args__`.
trusted_official_docs
CPython Docs
- *kw_only*: If true, this field will be marked as keyword-only. This is used when the generated :meth:`~object.__init__` method's parameters are computed. Keyword-only fields are also not included in :attr:`!__match_args__`.
- *kw_only*: If true, this field will be marked as keyword-only. This is used when the generated :meth:`~object.__init__` method's parameters are computed. Keyword-only fields are also not included in :attr:`!__match_args__`.
python, official-docs, cpython, P0
Local_Trusted_Corpus
642e5890-79d2-42d9-a881-8337566a651a
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,230
supabase-export-v2
2452620c4fbf1fc0
an instance of a dataclass. Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does not return pseudo-fields which are ``ClassVar`` or ``InitVar``. .. function:: asdict(obj, *, dict_factory=dict)
trusted_official_docs
CPython Docs
an instance of a dataclass. Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does not return pseudo-fields which are ``ClassVar`` or ``InitVar``. .. function:: asdict(obj, *, dict_factory=dict)
an instance of a dataclass. Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does not return pseudo-fields which are ``ClassVar`` or ``InitVar``. .. function:: asdict(obj, *, dict_factory=dict)
python, official-docs, cpython, P0
Local_Trusted_Corpus
6488739d-79d8-43d6-839b-8d920be07d7c
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,262
supabase-export-v2
6256053131aa8031
It is an error for *changes* to contain any fields that are defined as having ``init=False``. A :exc:`ValueError` will be raised in this case. Be forewarned about how ``init=False`` fields work during a call to :func:`!replace`. They are not copied from the source object, but rather are initialized in :meth:`__post_i...
trusted_official_docs
CPython Docs
It is an error for *changes* to contain any fields that are defined as having ``init=False``. A :exc:`ValueError` will be raised in this case. Be forewarned about how ``init=False`` fields work during a call to :func:`!replace`. They are not copied from the source object, but rather are initialized in :meth:`__post_i...
It is an error for *changes* to contain any fields that are defined as having ``init=False``. A :exc:`ValueError` will be raised in this case. Be forewarned about how ``init=False`` fields work during a call to :func:`!replace`. They are not copied from the source object, but rather are initialized in :meth:`__post_i...
python, official-docs, cpython, P0
Local_Trusted_Corpus
66996463-1ba4-45e4-82b3-79840549d3b8
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,294
supabase-export-v2
fb897b58c538e478
Class variables --------------- One of the few places where :deco:`dataclass` actually inspects the type of a field is to determine if a field is a class variable as defined in :pep:`526`. It does this by checking if the type of the field is :data:`typing.ClassVar`. If a field is a ``ClassVar``, it is excluded from con...
trusted_official_docs
CPython Docs
Class variables --------------- One of the few places where :deco:`dataclass` actually inspects the type of a field is to determine if a field is a class variable as defined in :pep:`526`. It does this by checking if the type of the field is :data:`typing.ClassVar`. If a field is a ``ClassVar``, it is excluded from con...
Class variables --------------- One of the few places where :deco:`dataclass` actually inspects the type of a field is to determine if a field is a class variable as defined in :pep:`526`. It does this by checking if the type of the field is :data:`typing.ClassVar`. If a field is a ``ClassVar``, it is excluded from con...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6871b8b4-b47b-42f5-9541-abdfa908fe14
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,314
supabase-export-v2
5799942c6372ffe7
The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. The final type of :attr:`!x` is :class:`int`, as specified in class :class:`!C`. The generated :meth:`~object.__init__` method for :class:`!C` will look like::
trusted_official_docs
CPython Docs
The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. The final type of :attr:`!x` is :class:`int`, as specified in class :class:`!C`. The generated :meth:`~object.__init__` method for :class:`!C` will look like::
The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. The final type of :attr:`!x` is :class:`int`, as specified in class :class:`!C`. The generated :meth:`~object.__init__` method for :class:`!C` will look like::
python, official-docs, cpython, P0
Local_Trusted_Corpus
6ae2f7f8-fa0b-4014-aa0f-ec0720cd0e82
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,271
supabase-export-v2
5e68c06c4e4cb714
.. data:: KW_ONLY A sentinel value used as a type annotation. Any fields after a pseudo-field with the type of :const:`!KW_ONLY` are marked as keyword-only fields. Note that a pseudo-field of type :const:`!KW_ONLY` is otherwise completely ignored. This includes the name of such a field. By convention, a name of ``_...
trusted_official_docs
CPython Docs
.. data:: KW_ONLY A sentinel value used as a type annotation. Any fields after a pseudo-field with the type of :const:`!KW_ONLY` are marked as keyword-only fields. Note that a pseudo-field of type :const:`!KW_ONLY` is otherwise completely ignored. This includes the name of such a field. By convention, a name of ``_...
.. data:: KW_ONLY A sentinel value used as a type annotation. Any fields after a pseudo-field with the type of :const:`!KW_ONLY` are marked as keyword-only fields. Note that a pseudo-field of type :const:`!KW_ONLY` is otherwise completely ignored. This includes the name of such a field. By convention, a name of ``_...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6b40b2cd-cf7c-4dbb-89c1-18bf6ddf8266
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,188
supabase-export-v2
abb7f7423b01f166
.. versionadded:: 3.10 - *slots*: If true (the default is ``False``), :attr:`~object.__slots__` attribute will be generated and new class will be returned instead of the original one. If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError` is raised.
trusted_official_docs
CPython Docs
.. versionadded:: 3.10 - *slots*: If true (the default is ``False``), :attr:`~object.__slots__` attribute will be generated and new class will be returned instead of the original one. If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError` is raised.
.. versionadded:: 3.10 - *slots*: If true (the default is ``False``), :attr:`~object.__slots__` attribute will be generated and new class will be returned instead of the original one. If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError` is raised.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6e45ecf7-cf91-4690-ae6f-381eb5258227
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,206
supabase-export-v2
be3995484b77fc7d
this will be the default value for this field. This is needed because the :func:`!field` call itself replaces the normal position of the default value. - *default_factory*: If provided, it must be a zero-argument callable that will be called when a default value is needed for this field. Among other purposes, this ca...
trusted_official_docs
CPython Docs
this will be the default value for this field. This is needed because the :func:`!field` call itself replaces the normal position of the default value. - *default_factory*: If provided, it must be a zero-argument callable that will be called when a default value is needed for this field. Among other purposes, this ca...
this will be the default value for this field. This is needed because the :func:`!field` call itself replaces the normal position of the default value. - *default_factory*: If provided, it must be a zero-argument callable that will be called when a default value is needed for this field. Among other purposes, this ca...
python, official-docs, cpython, P0
Local_Trusted_Corpus
70496535-8bb6-4558-8fd6-c0397ce4dcd4
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,324
supabase-export-v2
c0af5fc9a83c4a20
have been re-ordered from how they appear in the list of fields: parameters derived from regular fields are followed by parameters derived from keyword-only fields. The relative ordering of keyword-only parameters is maintained in the re-ordered :meth:`!__init__` parameter list.
trusted_official_docs
CPython Docs
have been re-ordered from how they appear in the list of fields: parameters derived from regular fields are followed by parameters derived from keyword-only fields. The relative ordering of keyword-only parameters is maintained in the re-ordered :meth:`!__init__` parameter list.
have been re-ordered from how they appear in the list of fields: parameters derived from regular fields are followed by parameters derived from keyword-only fields. The relative ordering of keyword-only parameters is maintained in the re-ordered :meth:`!__init__` parameter list.
python, official-docs, cpython, P0
Local_Trusted_Corpus
70bc5be4-a102-4a7a-9f60-cdd2094b3279
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,160
supabase-export-v2
e1872d95718407b5
class variable that has a :term:`type annotation <variable annotation>`. With two exceptions described below, nothing in ``@dataclass`` examines the type specified in the variable annotation. The order of the fields in all of the generated methods is the order in which they appear in the class definition.
trusted_official_docs
CPython Docs
class variable that has a :term:`type annotation <variable annotation>`. With two exceptions described below, nothing in ``@dataclass`` examines the type specified in the variable annotation. The order of the fields in all of the generated methods is the order in which they appear in the class definition.
class variable that has a :term:`type annotation <variable annotation>`. With two exceptions described below, nothing in ``@dataclass`` examines the type specified in the variable annotation. The order of the fields in all of the generated methods is the order in which they appear in the class definition.
python, official-docs, cpython, P0
Local_Trusted_Corpus
74a3e051-284b-4750-b9dc-a78a300b5961
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,323
supabase-export-v2
6bf1ce871549e084
def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: int = 0): Note that the parameters have been re-ordered from how they appear in the list of fields: parameters derived from regular fields are followed by parameters derived from keyword-only fields.
trusted_official_docs
CPython Docs
def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: int = 0): Note that the parameters have been re-ordered from how they appear in the list of fields: parameters derived from regular fields are followed by parameters derived from keyword-only fields.
def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: int = 0): Note that the parameters have been re-ordered from how they appear in the list of fields: parameters derived from regular fields are followed by parameters derived from keyword-only fields.
python, official-docs, cpython, P0
Local_Trusted_Corpus
75c0cd13-6ce0-4a4b-a03e-8eaa202774f7
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,286
supabase-export-v2
249ebdb7bff98717
def __post_init__(self): self.c = self.a + self.b The :meth:`~object.__init__` method generated by :deco:`dataclass` does not call base class :meth:`!__init__` methods. If the base class has an :meth:`!__init__` method that has to be called, it is common to call this method in a :meth:`__post_init__` method::
trusted_official_docs
CPython Docs
def __post_init__(self): self.c = self.a + self.b The :meth:`~object.__init__` method generated by :deco:`dataclass` does not call base class :meth:`!__init__` methods. If the base class has an :meth:`!__init__` method that has to be called, it is common to call this method in a :meth:`__post_init__` method::
def __post_init__(self): self.c = self.a + self.b The :meth:`~object.__init__` method generated by :deco:`dataclass` does not call base class :meth:`!__init__` methods. If the base class has an :meth:`!__init__` method that has to be called, it is common to call this method in a :meth:`__post_init__` method::
python, official-docs, cpython, P0
Local_Trusted_Corpus
791c6a1b-9a7f-476f-ac1e-8d6fe9572032
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,242
supabase-export-v2
81fe6c5dd603abbe
dataclass is converted to a tuple of its field values. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deepcopy`. Continuing from the previous example::
trusted_official_docs
CPython Docs
dataclass is converted to a tuple of its field values. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deepcopy`. Continuing from the previous example::
dataclass is converted to a tuple of its field values. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deepcopy`. Continuing from the previous example::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7af716f4-a9ef-49d6-a8b4-5f59ccc9621f
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,232
supabase-export-v2
106e7660fb62cb04
to a dict of its fields, as ``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deepcopy`. Example of using :func:`!asdict` on nested dataclasses::
trusted_official_docs
CPython Docs
to a dict of its fields, as ``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deepcopy`. Example of using :func:`!asdict` on nested dataclasses::
to a dict of its fields, as ``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples are recursed into. Other objects are copied with :func:`copy.deepcopy`. Example of using :func:`!asdict` on nested dataclasses::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7be2f5ae-ab2b-494f-936f-9d77f0a44be7
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,340
supabase-export-v2
00d5a8b9aade68b1
The assumption is that if a value is unhashable, it is mutable. This is a partial solution, but it does protect against many common errors. Using default factory functions is a way to create new instances of mutable types as default values for fields::
trusted_official_docs
CPython Docs
The assumption is that if a value is unhashable, it is mutable. This is a partial solution, but it does protect against many common errors. Using default factory functions is a way to create new instances of mutable types as default values for fields::
The assumption is that if a value is unhashable, it is mutable. This is a partial solution, but it does protect against many common errors. Using default factory functions is a way to create new instances of mutable types as default values for fields::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7deeee31-a6bb-4ca8-a0cb-468625fd3fb3
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,173
supabase-export-v2
187a4acb73ebd389
If the class already defines :meth:`!__eq__`, this parameter is ignored. - *order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods will be generated. These compare the class as if it were a tuple of its fields, in order. ...
trusted_official_docs
CPython Docs
If the class already defines :meth:`!__eq__`, this parameter is ignored. - *order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods will be generated. These compare the class as if it were a tuple of its fields, in order. ...
If the class already defines :meth:`!__eq__`, this parameter is ignored. - *order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods will be generated. These compare the class as if it were a tuple of its fields, in order. ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8491502a-b74e-4914-9c8c-66b110da785f
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,346
supabase-export-v2
7f456068d70effa9
Fields that are assigned :ref:`descriptor objects <descriptors>` as their default value have the following special behaviors: * The value for the field passed to the dataclass's :meth:`~object.__init__` method is passed to the descriptor's :meth:`~object.__set__` method rather than overwriting the descriptor object.
trusted_official_docs
CPython Docs
Fields that are assigned :ref:`descriptor objects <descriptors>` as their default value have the following special behaviors: * The value for the field passed to the dataclass's :meth:`~object.__init__` method is passed to the descriptor's :meth:`~object.__set__` method rather than overwriting the descriptor object.
Fields that are assigned :ref:`descriptor objects <descriptors>` as their default value have the following special behaviors: * The value for the field passed to the dataclass's :meth:`~object.__init__` method is passed to the descriptor's :meth:`~object.__set__` method rather than overwriting the descriptor object.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8581a387-d511-4202-ac8c-3235ef5635e7
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,326
supabase-export-v2
8b6dcf9c772f3f55
Default factory functions ------------------------- If a :func:`field` specifies a *default_factory*, it is called with zero arguments when a default value for the field is needed. For example, to create a new instance of a list, use::
trusted_official_docs
CPython Docs
Default factory functions ------------------------- If a :func:`field` specifies a *default_factory*, it is called with zero arguments when a default value for the field is needed. For example, to create a new instance of a list, use::
Default factory functions ------------------------- If a :func:`field` specifies a *default_factory*, it is called with zero arguments when a default value for the field is needed. For example, to create a new instance of a list, use::
python, official-docs, cpython, P0
Local_Trusted_Corpus
86f95c15-0592-4bc9-9caa-376830f721cb
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,172
supabase-export-v2
6b8fa357c177d179
compares the class as if it were a tuple of its fields, in order. Both instances in the comparison must be of the identical type. If the class already defines :meth:`!__eq__`, this parameter is ignored.
trusted_official_docs
CPython Docs
compares the class as if it were a tuple of its fields, in order. Both instances in the comparison must be of the identical type. If the class already defines :meth:`!__eq__`, this parameter is ignored.
compares the class as if it were a tuple of its fields, in order. Both instances in the comparison must be of the identical type. If the class already defines :meth:`!__eq__`, this parameter is ignored.
python, official-docs, cpython, P0
Local_Trusted_Corpus
87b08f9c-2370-4e17-907c-408a895c288f
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,322
supabase-export-v2
7dc7b541be3bdd6b
The generated :meth:`!__init__` method for :class:`!D` will look like:: def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: int = 0):
trusted_official_docs
CPython Docs
The generated :meth:`!__init__` method for :class:`!D` will look like:: def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: int = 0):
The generated :meth:`!__init__` method for :class:`!D` will look like:: def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: int = 0):
python, official-docs, cpython, P0
Local_Trusted_Corpus
8831ec1e-4654-4151-9a64-b5506c1b9a63
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,357
supabase-export-v2
206b09dd4ff1687a
i = InventoryItem() print(i.quantity_on_hand) # 100 i.quantity_on_hand = 2.5 # calls __set__ with 2.5 print(i.quantity_on_hand) # 2 Note that if a field is annotated with a descriptor type, but is not assigned a descriptor object as its default value, the field will act like a normal field.
trusted_official_docs
CPython Docs
i = InventoryItem() print(i.quantity_on_hand) # 100 i.quantity_on_hand = 2.5 # calls __set__ with 2.5 print(i.quantity_on_hand) # 2 Note that if a field is annotated with a descriptor type, but is not assigned a descriptor object as its default value, the field will act like a normal field.
i = InventoryItem() print(i.quantity_on_hand) # 100 i.quantity_on_hand = 2.5 # calls __set__ with 2.5 print(i.quantity_on_hand) # 2 Note that if a field is annotated with a descriptor type, but is not assigned a descriptor object as its default value, the field will act like a normal field.
python, official-docs, cpython, P0
Local_Trusted_Corpus
883ea3ab-1afc-4180-b4f5-d5edaa8fdb8a
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,300
supabase-export-v2
d5e49e5a1a43297d
@dataclass class C: i: int j: int | None = None database: InitVar[DatabaseType | None] = None def __post_init__(self, database): if self.j is None and database is not None: self.j = database.lookup('j')
trusted_official_docs
CPython Docs
@dataclass class C: i: int j: int | None = None database: InitVar[DatabaseType | None] = None def __post_init__(self, database): if self.j is None and database is not None: self.j = database.lookup('j')
@dataclass class C: i: int j: int | None = None database: InitVar[DatabaseType | None] = None def __post_init__(self, database): if self.j is None and database is not None: self.j = database.lookup('j')
python, official-docs, cpython, P0
Local_Trusted_Corpus
913c029c-8952-45c0-a6b8-9cff292c8f66
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,298
supabase-export-v2
990378458df98d4f
fields are added as parameters to the generated :meth:`~object.__init__` method, and are passed to the optional :meth:`__post_init__` method. They are not otherwise used by dataclasses. For example, suppose a field will be initialized from a database, if a value is not provided when creating the class::
trusted_official_docs
CPython Docs
fields are added as parameters to the generated :meth:`~object.__init__` method, and are passed to the optional :meth:`__post_init__` method. They are not otherwise used by dataclasses. For example, suppose a field will be initialized from a database, if a value is not provided when creating the class::
fields are added as parameters to the generated :meth:`~object.__init__` method, and are passed to the optional :meth:`__post_init__` method. They are not otherwise used by dataclasses. For example, suppose a field will be initialized from a database, if a value is not provided when creating the class::
python, official-docs, cpython, P0
Local_Trusted_Corpus
9530ecd1-99c7-493c-bc75-00738f57af85
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,343
supabase-export-v2
d38d540dc88d2444
assert D().x is not D().x .. versionchanged:: 3.11 Instead of looking for and disallowing objects of type :class:`list`, :class:`dict`, or :class:`set`, unhashable objects are now not allowed as default values. Unhashability is used to approximate mutability.
trusted_official_docs
CPython Docs
assert D().x is not D().x .. versionchanged:: 3.11 Instead of looking for and disallowing objects of type :class:`list`, :class:`dict`, or :class:`set`, unhashable objects are now not allowed as default values. Unhashability is used to approximate mutability.
assert D().x is not D().x .. versionchanged:: 3.11 Instead of looking for and disallowing objects of type :class:`list`, :class:`dict`, or :class:`set`, unhashable objects are now not allowed as default values. Unhashability is used to approximate mutability.
python, official-docs, cpython, P0
Local_Trusted_Corpus
95782073-ca66-458a-b8e8-903492da08a9
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,219
supabase-export-v2
0216331eada96f69
runs, the class attributes will all contain the default values for the fields, just as if the default value itself were specified. For example, after:: @dataclass class C: x: int y: int = field(repr=False) z: int = field(repr=False, default=10) t: int = 20
trusted_official_docs
CPython Docs
runs, the class attributes will all contain the default values for the fields, just as if the default value itself were specified. For example, after:: @dataclass class C: x: int y: int = field(repr=False) z: int = field(repr=False, default=10) t: int = 20
runs, the class attributes will all contain the default values for the fields, just as if the default value itself were specified. For example, after:: @dataclass class C: x: int y: int = field(repr=False) z: int = field(repr=False, default=10) t: int = 20
python, official-docs, cpython, P0
Local_Trusted_Corpus
95ae6cac-f5e6-4ef7-afda-f22649a0140e
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,283
supabase-export-v2
f13f51382838884d
passed to :meth:`!__post_init__` in the order they were defined in the class. If no :meth:`!__init__` method is generated, then :meth:`!__post_init__` will not automatically be called. Among other uses, this allows for initializing field values that depend on one or more other fields. For example::
trusted_official_docs
CPython Docs
passed to :meth:`!__post_init__` in the order they were defined in the class. If no :meth:`!__init__` method is generated, then :meth:`!__post_init__` will not automatically be called. Among other uses, this allows for initializing field values that depend on one or more other fields. For example::
passed to :meth:`!__post_init__` in the order they were defined in the class. If no :meth:`!__init__` method is generated, then :meth:`!__post_init__` will not automatically be called. Among other uses, this allows for initializing field values that depend on one or more other fields. For example::
python, official-docs, cpython, P0
Local_Trusted_Corpus
968b9e29-d506-401f-b19b-a46ae9282447
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,305
supabase-export-v2
16f1bf395954b0d0
Frozen instances ---------------- It is not possible to create truly immutable Python objects. However, by passing ``frozen=True`` to the :deco:`dataclass` decorator you can emulate immutability. In that case, dataclasses will add :meth:`~object.__setattr__` and :meth:`~object.__delattr__` methods to the class. These m...
trusted_official_docs
CPython Docs
Frozen instances ---------------- It is not possible to create truly immutable Python objects. However, by passing ``frozen=True`` to the :deco:`dataclass` decorator you can emulate immutability. In that case, dataclasses will add :meth:`~object.__setattr__` and :meth:`~object.__delattr__` methods to the class. These m...
Frozen instances ---------------- It is not possible to create truly immutable Python objects. However, by passing ``frozen=True`` to the :deco:`dataclass` decorator you can emulate immutability. In that case, dataclasses will add :meth:`~object.__setattr__` and :meth:`~object.__delattr__` methods to the class. These m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9984a491-8a66-4e57-b105-8b4cbd3e22d4
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,170
supabase-export-v2
557efdeb9ffa6074
order they are defined in the class. Fields that are marked as being excluded from the repr are not included. For example: ``InventoryItem(name='widget', unit_price=3.0, quantity_on_hand=10)``. If the class already defines :meth:`!__repr__`, this parameter is ignored.
trusted_official_docs
CPython Docs
order they are defined in the class. Fields that are marked as being excluded from the repr are not included. For example: ``InventoryItem(name='widget', unit_price=3.0, quantity_on_hand=10)``. If the class already defines :meth:`!__repr__`, this parameter is ignored.
order they are defined in the class. Fields that are marked as being excluded from the repr are not included. For example: ``InventoryItem(name='widget', unit_price=3.0, quantity_on_hand=10)``. If the class already defines :meth:`!__repr__`, this parameter is ignored.
python, official-docs, cpython, P0
Local_Trusted_Corpus
99eaaba4-b422-4a65-9598-f884ea4b6828
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,148
supabase-export-v2
447c9ac4259095f1
decorator and functions for automatically adding generated :term:`special methods <special method>` such as :meth:`~object.__init__` and :meth:`~object.__repr__` to user-defined classes. It was originally described in :pep:`557`. The member variables to use in these generated methods are defined using :pep:`526` type a...
trusted_official_docs
CPython Docs
decorator and functions for automatically adding generated :term:`special methods <special method>` such as :meth:`~object.__init__` and :meth:`~object.__repr__` to user-defined classes. It was originally described in :pep:`557`. The member variables to use in these generated methods are defined using :pep:`526` type a...
decorator and functions for automatically adding generated :term:`special methods <special method>` such as :meth:`~object.__init__` and :meth:`~object.__repr__` to user-defined classes. It was originally described in :pep:`557`. The member variables to use in these generated methods are defined using :pep:`526` type a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9c7846ef-ec0c-4799-b503-3010689da7a4
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,191
supabase-export-v2
b8b7a9fa8e975e58
.. versionadded:: 3.10 .. versionchanged:: 3.11 If a field name is already included in the :attr:`!__slots__` of a base class, it will not be included in the generated :attr:`!__slots__` to prevent :ref:`overriding them <datamodel-note-slots>`. Therefore, do not use :attr:`!__slots__` to retrieve the field names of ...
trusted_official_docs
CPython Docs
.. versionadded:: 3.10 .. versionchanged:: 3.11 If a field name is already included in the :attr:`!__slots__` of a base class, it will not be included in the generated :attr:`!__slots__` to prevent :ref:`overriding them <datamodel-note-slots>`. Therefore, do not use :attr:`!__slots__` to retrieve the field names of ...
.. versionadded:: 3.10 .. versionchanged:: 3.11 If a field name is already included in the :attr:`!__slots__` of a base class, it will not be included in the generated :attr:`!__slots__` to prevent :ref:`overriding them <datamodel-note-slots>`. Therefore, do not use :attr:`!__slots__` to retrieve the field names of ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9e0d3ffd-242f-4be6-9979-be85e963ab5c
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,189
supabase-export-v2
b51fa60245ab6216
be generated and new class will be returned instead of the original one. If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError` is raised. .. warning:: Passing parameters to a base class :meth:`~object.__init_subclass__` when using ``slots=True`` will result in a :exc:`TypeError`. Either use ``_...
trusted_official_docs
CPython Docs
be generated and new class will be returned instead of the original one. If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError` is raised. .. warning:: Passing parameters to a base class :meth:`~object.__init_subclass__` when using ``slots=True`` will result in a :exc:`TypeError`. Either use ``_...
be generated and new class will be returned instead of the original one. If :attr:`!__slots__` is already defined in the class, then :exc:`TypeError` is raised. .. warning:: Passing parameters to a base class :meth:`~object.__init_subclass__` when using ``slots=True`` will result in a :exc:`TypeError`. Either use ``_...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a6aa59ae-0335-4f04-9944-e9d46d0c748c
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,259
supabase-export-v2
09c3ee2e2efc9127
from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If keys in *changes* are not field names of the given dataclass, raises :exc:`TypeError`. The newly returned object is created by calling the :meth:`~object.__init__` method of the dataclass. This ensures that :meth:`__post_init__`, if present, is...
trusted_official_docs
CPython Docs
from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If keys in *changes* are not field names of the given dataclass, raises :exc:`TypeError`. The newly returned object is created by calling the :meth:`~object.__init__` method of the dataclass. This ensures that :meth:`__post_init__`, if present, is...
from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If keys in *changes* are not field names of the given dataclass, raises :exc:`TypeError`. The newly returned object is created by calling the :meth:`~object.__init__` method of the dataclass. This ensures that :meth:`__post_init__`, if present, is...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a78a5d67-e1e9-48c1-a7d7-7eeda6d56e5d
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,299
supabase-export-v2
7c2d2326b109e31d
For example, suppose a field will be initialized from a database, if a value is not provided when creating the class:: @dataclass class C: i: int j: int | None = None database: InitVar[DatabaseType | None] = None
trusted_official_docs
CPython Docs
For example, suppose a field will be initialized from a database, if a value is not provided when creating the class:: @dataclass class C: i: int j: int | None = None database: InitVar[DatabaseType | None] = None
For example, suppose a field will be initialized from a database, if a value is not provided when creating the class:: @dataclass class C: i: int j: int | None = None database: InitVar[DatabaseType | None] = None
python, official-docs, cpython, P0
Local_Trusted_Corpus
a8a18302-890a-4f26-89c7-b72510db6f10
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,287
supabase-export-v2
a8c2b3f0af2f81ad
methods. If the base class has an :meth:`!__init__` method that has to be called, it is common to call this method in a :meth:`__post_init__` method:: class Rectangle: def __init__(self, height, width): self.height = height self.width = width
trusted_official_docs
CPython Docs
methods. If the base class has an :meth:`!__init__` method that has to be called, it is common to call this method in a :meth:`__post_init__` method:: class Rectangle: def __init__(self, height, width): self.height = height self.width = width
methods. If the base class has an :meth:`!__init__` method that has to be called, it is common to call this method in a :meth:`__post_init__` method:: class Rectangle: def __init__(self, height, width): self.height = height self.width = width
python, official-docs, cpython, P0
Local_Trusted_Corpus
a9e7f0c5-c6d1-405b-8172-fffd8fc0c872
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,175
supabase-export-v2
9fc169fd5f595381
If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised. - *unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object.__hash__` method, even though it may not be safe to do so. Otherwise, generate a :meth:`~object.__hash__...
trusted_official_docs
CPython Docs
If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised. - *unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object.__hash__` method, even though it may not be safe to do so. Otherwise, generate a :meth:`~object.__hash__...
If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised. - *unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object.__hash__` method, even though it may not be safe to do so. Otherwise, generate a :meth:`~object.__hash__...
python, official-docs, cpython, P0
Local_Trusted_Corpus
abb0a665-7acd-4ed6-9b01-c2b3676220f3
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,227
supabase-export-v2
94a7ce2d6fd27fe6
.. class:: InitVar ``InitVar[T]`` type annotations describe variables that are :ref:`init-only <dataclasses-init-only-variables>`. Fields annotated with :class:`!InitVar` are considered pseudo-fields, and thus are neither returned by the :func:`fields` function nor used in any way except adding them as parameters t...
trusted_official_docs
CPython Docs
.. class:: InitVar ``InitVar[T]`` type annotations describe variables that are :ref:`init-only <dataclasses-init-only-variables>`. Fields annotated with :class:`!InitVar` are considered pseudo-fields, and thus are neither returned by the :func:`fields` function nor used in any way except adding them as parameters t...
.. class:: InitVar ``InitVar[T]`` type annotations describe variables that are :ref:`init-only <dataclasses-init-only-variables>`. Fields annotated with :class:`!InitVar` are considered pseudo-fields, and thus are neither returned by the :func:`fields` function nor used in any way except adding them as parameters t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b0fbb15a-5a44-4654-bc07-10f93a24f0ae
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,291
supabase-export-v2
39405ae811178e70
don't need to be called, since the derived dataclass will take care of initializing all fields of any base class that is a dataclass itself. See the section below on init-only variables for ways to pass parameters to :meth:`!__post_init__`. Also see the warning about how :func:`replace` handles ``init=False`` fields.
trusted_official_docs
CPython Docs
don't need to be called, since the derived dataclass will take care of initializing all fields of any base class that is a dataclass itself. See the section below on init-only variables for ways to pass parameters to :meth:`!__post_init__`. Also see the warning about how :func:`replace` handles ``init=False`` fields.
don't need to be called, since the derived dataclass will take care of initializing all fields of any base class that is a dataclass itself. See the section below on init-only variables for ways to pass parameters to :meth:`!__post_init__`. Also see the warning about how :func:`replace` handles ``init=False`` fields.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b2116850-634f-4161-82b7-df477c0d2120
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,203
supabase-export-v2
f09981d8b2ac7949
c = C() c.mylist += [1, 2, 3] As shown above, the :const:`MISSING` value is a sentinel object used to detect if some parameters are provided by the user. This sentinel is used because ``None`` is a valid value for some parameters with a distinct meaning. No code should directly use the :const:`MISSING` value.
trusted_official_docs
CPython Docs
c = C() c.mylist += [1, 2, 3] As shown above, the :const:`MISSING` value is a sentinel object used to detect if some parameters are provided by the user. This sentinel is used because ``None`` is a valid value for some parameters with a distinct meaning. No code should directly use the :const:`MISSING` value.
c = C() c.mylist += [1, 2, 3] As shown above, the :const:`MISSING` value is a sentinel object used to detect if some parameters are provided by the user. This sentinel is used because ``None`` is a valid value for some parameters with a distinct meaning. No code should directly use the :const:`MISSING` value.
python, official-docs, cpython, P0
Local_Trusted_Corpus
b418e602-6026-4c3e-92dc-8c59b95ace1a
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,178
supabase-export-v2
73c7ae82dfd70dcb
an existing explicitly defined :meth:`!__hash__` method. Setting the class attribute ``__hash__ = None`` has a specific meaning to Python, as described in the :meth:`!__hash__` documentation. If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, then ``@dataclass`` *may* add an implicit :meth:`!...
trusted_official_docs
CPython Docs
an existing explicitly defined :meth:`!__hash__` method. Setting the class attribute ``__hash__ = None`` has a specific meaning to Python, as described in the :meth:`!__hash__` documentation. If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, then ``@dataclass`` *may* add an implicit :meth:`!...
an existing explicitly defined :meth:`!__hash__` method. Setting the class attribute ``__hash__ = None`` has a specific meaning to Python, as described in the :meth:`!__hash__` documentation. If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, then ``@dataclass`` *may* add an implicit :meth:`!...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b810c0f1-c14c-49a2-8b34-d32dcb2aeed6
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,282
supabase-export-v2
b98873782744ee4f
.. function:: __post_init__() When defined on the class, it will be called by the generated :meth:`~object.__init__`, normally as :meth:`!self.__post_init__`. However, if any ``InitVar`` fields are defined, they will also be passed to :meth:`!__post_init__` in the order they were defined in the class. If no :meth:`!...
trusted_official_docs
CPython Docs
.. function:: __post_init__() When defined on the class, it will be called by the generated :meth:`~object.__init__`, normally as :meth:`!self.__post_init__`. However, if any ``InitVar`` fields are defined, they will also be passed to :meth:`!__post_init__` in the order they were defined in the class. If no :meth:`!...
.. function:: __post_init__() When defined on the class, it will be called by the generated :meth:`~object.__init__`, normally as :meth:`!self.__post_init__`. However, if any ``InitVar`` fields are defined, they will also be passed to :meth:`!__post_init__` in the order they were defined in the class. If no :meth:`!...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bc18a768-8e25-4cc0-a093-bb97aa331c4c
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,333
supabase-export-v2
5c9888e33986b959
o1 = C() o2 = C() o1.add(1) o2.add(2) assert o1.x == [1, 2] assert o1.x is o2.x Note that the two instances of class :class:`!C` share the same class variable :attr:`!x`, as expected.
trusted_official_docs
CPython Docs
o1 = C() o2 = C() o1.add(1) o2.add(2) assert o1.x == [1, 2] assert o1.x is o2.x Note that the two instances of class :class:`!C` share the same class variable :attr:`!x`, as expected.
o1 = C() o2 = C() o1.add(1) o2.add(2) assert o1.x == [1, 2] assert o1.x is o2.x Note that the two instances of class :class:`!C` share the same class variable :attr:`!x`, as expected.
python, official-docs, cpython, P0
Local_Trusted_Corpus
bf97b059-5437-45be-8d6d-92c69d75898d
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,348
supabase-export-v2
d146d11a1d62aa12
* Similarly, when getting or setting the field, the descriptor's :meth:`~object.__get__` or :meth:`!__set__` method is called rather than returning or overwriting the descriptor object. * To determine whether a field contains a default value, :deco:`dataclass` will call the descriptor's :meth:`!__get__` method using i...
trusted_official_docs
CPython Docs
* Similarly, when getting or setting the field, the descriptor's :meth:`~object.__get__` or :meth:`!__set__` method is called rather than returning or overwriting the descriptor object. * To determine whether a field contains a default value, :deco:`dataclass` will call the descriptor's :meth:`!__get__` method using i...
* Similarly, when getting or setting the field, the descriptor's :meth:`~object.__get__` or :meth:`!__set__` method is called rather than returning or overwriting the descriptor object. * To determine whether a field contains a default value, :deco:`dataclass` will call the descriptor's :meth:`!__get__` method using i...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c18e5459-0c35-40d3-9eb7-b75c6b79cbd5
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,205
supabase-export-v2
d9eddef4fdf40fa2
The parameters to :func:`!field` are: - *default*: If provided, this will be the default value for this field. This is needed because the :func:`!field` call itself replaces the normal position of the default value.
trusted_official_docs
CPython Docs
The parameters to :func:`!field` are: - *default*: If provided, this will be the default value for this field. This is needed because the :func:`!field` call itself replaces the normal position of the default value.
The parameters to :func:`!field` are: - *default*: If provided, this will be the default value for this field. This is needed because the :func:`!field` call itself replaces the normal position of the default value.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c684d416-5d9c-42fc-bc9c-91c47646cb1b
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,339
supabase-export-v2
456aa46249a351c8
assert D().x is D().x This has the same issue as the original example using class :class:`!C`. That is, two instances of class :class:`!D` that do not specify a value for :attr:`!x` when creating a class instance will share the same copy of :attr:`!x`. Because dataclasses just use normal Python class creation they also...
trusted_official_docs
CPython Docs
assert D().x is D().x This has the same issue as the original example using class :class:`!C`. That is, two instances of class :class:`!D` that do not specify a value for :attr:`!x` when creating a class instance will share the same copy of :attr:`!x`. Because dataclasses just use normal Python class creation they also...
assert D().x is D().x This has the same issue as the original example using class :class:`!C`. That is, two instances of class :class:`!D` that do not specify a value for :attr:`!x` when creating a class instance will share the same copy of :attr:`!x`. Because dataclasses just use normal Python class creation they also...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c8363b58-3db3-4f48-9fb2-48ce7ab0e74b
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,183
supabase-export-v2
675eca32535be300
If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class and *frozen* is true, then :exc:`TypeError` is raised. - *match_args*: If true (the default is ``True``), the :attr:`~object.__match_args__` tuple will be created from the list of non keyword-only parameters to the generated :meth:`...
trusted_official_docs
CPython Docs
If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class and *frozen* is true, then :exc:`TypeError` is raised. - *match_args*: If true (the default is ``True``), the :attr:`~object.__match_args__` tuple will be created from the list of non keyword-only parameters to the generated :meth:`...
If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class and *frozen* is true, then :exc:`TypeError` is raised. - *match_args*: If true (the default is ``True``), the :attr:`~object.__match_args__` tuple will be created from the list of non keyword-only parameters to the generated :meth:`...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cb544a67-1c5d-4fa7-af36-165463a36df9
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,180
supabase-export-v2
3511d3c95954b4f4
a :meth:`!__hash__` method. Note that you cannot both have an explicit :meth:`!__hash__` method in your dataclass and set ``unsafe_hash=True``; this will result in a :exc:`TypeError`. If *eq* and *frozen* are both true, by default ``@dataclass`` will generate a :meth:`!__hash__` method for you. If *eq* is true and *f...
trusted_official_docs
CPython Docs
a :meth:`!__hash__` method. Note that you cannot both have an explicit :meth:`!__hash__` method in your dataclass and set ``unsafe_hash=True``; this will result in a :exc:`TypeError`. If *eq* and *frozen* are both true, by default ``@dataclass`` will generate a :meth:`!__hash__` method for you. If *eq* is true and *f...
a :meth:`!__hash__` method. Note that you cannot both have an explicit :meth:`!__hash__` method in your dataclass and set ``unsafe_hash=True``; this will result in a :exc:`TypeError`. If *eq* and *frozen* are both true, by default ``@dataclass`` will generate a :meth:`!__hash__` method for you. If *eq* is true and *f...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cc5c9e27-409d-4674-8c10-fd1719b00d7e
CPython Docs
file://datasets/cpython/Doc/library/dataclasses.rst
unknown
728fa76a-0041-43a1-a7a5-465d49abb21b
5,196
supabase-export-v2
7eec8d8eec51dbda
@dataclass class C: a: int # 'a' has no default value b: int = 0 # assign a default value for 'b' In this example, both :attr:`!a` and :attr:`!b` will be included in the added :meth:`~object.__init__` method, which will be defined as::
trusted_official_docs
CPython Docs
@dataclass class C: a: int # 'a' has no default value b: int = 0 # assign a default value for 'b' In this example, both :attr:`!a` and :attr:`!b` will be included in the added :meth:`~object.__init__` method, which will be defined as::
@dataclass class C: a: int # 'a' has no default value b: int = 0 # assign a default value for 'b' In this example, both :attr:`!a` and :attr:`!b` will be included in the added :meth:`~object.__init__` method, which will be defined as::
python, official-docs, cpython, P0
Local_Trusted_Corpus