Skip to content

Commit efeb8a2

Browse files
[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 f303651) Co-authored-by: Gouvernathor <[email protected]>
1 parent 222d16a commit efeb8a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/library/dataclasses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Module contents
362362

363363
To create a shallow copy, the following workaround may be used::
364364

365-
dict((field.name, getattr(obj, field.name)) for field in fields(obj))
365+
{field.name: getattr(obj, field.name) for field in fields(obj)}
366366

367367
:func:`!asdict` raises :exc:`TypeError` if ``obj`` is not a dataclass
368368
instance.

0 commit comments

Comments
 (0)