Simpler example of shallow dict export of a dataclass (#117812)

This commit is contained in:
Gouvernathor 2024-04-14 02:14:43 +02:00 committed by GitHub
parent e7cce2a9c6
commit f303651b45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -362,7 +362,7 @@ Module contents
To create a shallow copy, the following workaround may be used::
dict((field.name, getattr(obj, field.name)) for field in fields(obj))
{field.name: getattr(obj, field.name) for field in fields(obj)}
:func:`!asdict` raises :exc:`TypeError` if ``obj`` is not a dataclass
instance.