Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1932,10 +1932,12 @@ 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). The
``__prepare__`` method should be implemented as a :func:`classmethod`.
``__prepare__`` method should be implemented as a :func:`classmethod`. The
namespace returned by ``__prepare__`` is passed in to ``__new__``, but when
the final class object is created the namespace is copied into a new ``dict``.

If the metaclass has no ``__prepare__`` attribute, then the class namespace
is initialised as an empty ordered mapping.
is initialised as an empty :func:`dict`.

.. seealso::

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The language reference now specifies restrictions on class namespaces. Adapted from a patch by Ethan Furman.