Skip to content

Commit f303651

Browse files
authored
Simpler example of shallow dict export of a dataclass (#117812)
1 parent e7cce2a commit f303651

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)