]> granicus.if.org Git - python/commitdiff
Add example for PEP 557. (GH-5383)
authorEric V. Smith <ericvsmith@users.noreply.github.com>
Sun, 28 Jan 2018 14:25:45 +0000 (09:25 -0500)
committerGitHub <noreply@github.com>
Sun, 28 Jan 2018 14:25:45 +0000 (09:25 -0500)
Doc/whatsnew/3.7.rst

index 5e355345e31dc146919c1405d7423a14a694f872..9979e69239907a2b09513b6534175e0e284f04eb 100644 (file)
@@ -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