summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorEric V. Smith <ericvsmith@users.noreply.github.com>2018-01-28 14:25:45 (GMT)
committerGitHub <noreply@github.com>2018-01-28 14:25:45 (GMT)
commit4d0296649a48ff9dbc290394ff656cf3dea86107 (patch)
treeedffab7bd7c0117c96a9c31cf1aa34ee6a67c484 /Doc/whatsnew
parentf0a95f27c043e847a23940534fdfc53e1b3e31a1 (diff)
downloadcpython-4d0296649a48ff9dbc290394ff656cf3dea86107.zip
cpython-4d0296649a48ff9dbc290394ff656cf3dea86107.tar.gz
cpython-4d0296649a48ff9dbc290394ff656cf3dea86107.tar.bz2
Add example for PEP 557. (GH-5383)
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.7.rst11
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index 5e35534..9979e69 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