mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
Simpler example of shallow dict export of a dataclass (#117812)
This commit is contained in:
parent
e7cce2a9c6
commit
f303651b45
1 changed files with 1 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue