From 48cb95e838337b41be5e4c8e19f1e5203b7d969d Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:25:23 +0200 Subject: [PATCH] Better example of dict shallow copy --- Doc/library/dataclasses.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 61b2263339da71..d417b4fd015969 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -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.