https://github.com/python/cpython/commit/05008c27b73da640b63c0d335c65ade517c0eb84
commit: 05008c27b73da640b63c0d335c65ade517c0eb84
branch: main
author: Steffen Zeile <48187781+kan...@users.noreply.github.com>
committer: ericvsmith <ericvsm...@users.noreply.github.com>
date: 2024-01-16T20:17:34-05:00
summary:

gh-88531 Fix dataclass __post_init__/__init__ interplay documentation 
(gh-107404)

* Simplify __post_init__ example usage. It applies to all base classes, not 
just dataclasses.

files:
M Doc/library/dataclasses.rst

diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index bbbbcb00d8fef8..cde147d1cbb501 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -536,10 +536,10 @@ class :meth:`~object.__init__` methods. If the base class 
has an :meth:`~object.
 that has to be called, it is common to call this method in a
 :meth:`__post_init__` method::
 
-    @dataclass
     class Rectangle:
-        height: float
-        width: float
+        def __init__(self, height, width):
+          self.height = height
+          self.width = width
 
     @dataclass
     class Square(Rectangle):

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to