https://github.com/python/cpython/commit/efeb8a24b82627bafeea7e6f6c42971fa866051c
commit: efeb8a24b82627bafeea7e6f6c42971fa866051c
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: hauntsaninja <[email protected]>
date: 2024-04-14T00:22:35Z
summary:

[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 f303651b45649392bf718f970793ad65d9ded0b8)

Co-authored-by: Gouvernathor <[email protected]>

files:
M Doc/library/dataclasses.rst

diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index c038d5513ac44c..ae90d85e8d3149 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.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to