[3.12] Simpler example of shallow dict export of a dataclass (GH-117812) (#117862)

Simpler example of shallow dict export of a dataclass (GH-117812)
(cherry picked from commit f303651b45)

Co-authored-by: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-04-14 02:22:35 +02:00 committed by GitHub
parent 222d16a18c
commit efeb8a24b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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.