Unverified Kaydet (Commit) 4d029664 authored tarafından Eric V. Smith's avatar Eric V. Smith Kaydeden (comit) GitHub

Add example for PEP 557. (GH-5383)

üst f0a95f27
...@@ -323,6 +323,17 @@ Adds a new module ``dataclasses``. It provides a class decorator ...@@ -323,6 +323,17 @@ Adds a new module ``dataclasses``. It provides a class decorator
``typing.NamedTuple``, but also works on classes with mutable ``typing.NamedTuple``, but also works on classes with mutable
instances, among other features. 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:: .. seealso::
:pep:`557` -- Data Classes :pep:`557` -- Data Classes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment