[docs] Misleading documentation for __prepare__ (issue 15243)
wkschwartz at gmail.com
wkschwartz at gmail.com
Fri Jun 17 11:58:10 EDT 2016
Reviewers: ,
Message:
This looks good and solves my original concern.
Please review this at http://bugs.python.org/review/15243/
Affected files:
Doc/reference/datamodel.rst
diff -r 7efe1a5239e3 Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst Fri Jun 17 11:13:03 2016 +0300
+++ b/Doc/reference/datamodel.rst Fri Jun 17 16:26:41 2016 +0530
@@ -1687,7 +1687,9 @@
Once the appropriate metaclass has been identified, then the class namespace
is prepared. If the metaclass has a ``__prepare__`` attribute, it is called
as ``namespace = metaclass.__prepare__(name, bases, **kwds)`` (where the
-additional keyword arguments, if any, come from the class definition).
+additional keyword arguments, if any, come from the class definition). The
+``__prepare__`` method should be implimented as :func:`classmethod`. Observe
+:ref:`metaclass-example` for demonstration.
If the metaclass has no ``__prepare__`` attribute, then the class namespace
is initialised as an empty :func:`dict` instance.
@@ -1744,6 +1746,8 @@
Describes the implicit ``__class__`` closure reference
+.. _metaclass-example:
+
Metaclass example
^^^^^^^^^^^^^^^^^
More information about the docs
mailing list