[Python-checkins] Add example for PEP 557. (GH-5383)

Eric V. Smith webhook-mailer at python.org
Sun Jan 28 09:25:47 EST 2018


https://github.com/python/cpython/commit/4d0296649a48ff9dbc290394ff656cf3dea86107
commit: 4d0296649a48ff9dbc290394ff656cf3dea86107
branch: master
author: Eric V. Smith <ericvsmith at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-01-28T09:25:45-05:00
summary:

Add example for PEP 557. (GH-5383)

files:
M Doc/whatsnew/3.7.rst

diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index 5e355345e31d..9979e6923990 100644
--- a/Doc/whatsnew/3.7.rst
+++ b/Doc/whatsnew/3.7.rst
@@ -323,6 +323,17 @@ Adds a new module ``dataclasses``.  It provides a class decorator
 ``typing.NamedTuple``, but also works on classes with mutable
 instances, among other features.
 
+For example::
+
+    @dataclass
+    class Point:
+        x: float
+        y: float
+        z: float = 0.0
+
+    p = Point(1.5, 2.5)
+    print(p)   # produces "Point(x=1.5, y=2.5, z=0.0)"
+
 .. seealso::
 
     :pep:`557` -- Data Classes



More information about the Python-checkins mailing list