Add example for PEP 557. (GH-5383)

This commit is contained in:
Eric V. Smith 2018-01-28 09:25:45 -05:00 committed by GitHub
parent f0a95f27c0
commit 4d0296649a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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