Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0cf90e

Browse files
committed
Close #14947: add missing cross-reference to Language Definition from the new dynamic type creation functions. Also cleaned up the general wording of the docs
1 parent bb75678 commit a0cf90e

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

Doc/library/types.rst

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,40 @@ Dynamic Type Creation
2323

2424
Creates a class object dynamically using the appropriate metaclass.
2525

26-
The arguments are the components that make up a class definition: the
27-
class name, the base classes (in order), the keyword arguments (such as
28-
``metaclass``) and the callback function to populate the class namespace.
26+
The first three arguments are the components that make up a class
27+
definition header: the class name, the base classes (in order), the
28+
keyword arguments (such as ``metaclass``).
2929

30-
The *exec_body* callback should accept the class namespace as its sole
31-
argument and update the namespace directly with the class contents.
30+
The *exec_body* argument is a callback that is used to populate the
31+
freshly created class namespace. It should accept the class namespace
32+
as its sole argument and update the namespace directly with the class
33+
contents. If no callback is provided, it has the same effect as passing
34+
in ``lambda ns: ns``.
3235

3336
.. versionadded:: 3.3
3437

3538
.. function:: prepare_class(name, bases=(), kwds=None)
3639

3740
Calculates the appropriate metaclass and creates the class namespace.
3841

39-
The arguments are the components that make up a class definition: the
40-
class name, the base classes (in order) and the keyword arguments (such as
41-
``metaclass``).
42+
The arguments are the components that make up a class definition header:
43+
the class name, the base classes (in order) and the keyword arguments
44+
(such as ``metaclass``).
4245

4346
The return value is a 3-tuple: ``metaclass, namespace, kwds``
4447

45-
*metaclass* is the appropriate metaclass
46-
*namespace* is the prepared class namespace
47-
*kwds* is an updated copy of the passed in *kwds* argument with any
48-
``'metaclass'`` entry removed. If no *kwds* argument is passed in, this
49-
will be an empty dict.
48+
*metaclass* is the appropriate metaclass, *namespace* is the
49+
prepared class namespace and *kwds* is an updated copy of the passed
50+
in *kwds* argument with any ``'metaclass'`` entry removed. If no *kwds*
51+
argument is passed in, this will be an empty dict.
5052

5153
.. versionadded:: 3.3
5254

5355
.. seealso::
5456

57+
:ref:`metaclasses`
58+
Full details of the class creation process supported by these functions
59+
5560
:pep:`3115` - Metaclasses in Python 3000
5661
Introduced the ``__prepare__`` namespace hook
5762

0 commit comments

Comments
 (0)