diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-25 17:56:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-25 17:56:07 (GMT) |
commit | 86a36b500a7f7581194382ce4df914e4bb487873 (patch) | |
tree | 0d83f90f9a14d40d3559ae188c203e9c8941c6db /Doc | |
parent | 0e86a5842d0fadff37c299e8a1c03535c6727b19 (diff) | |
download | cpython-86a36b500a7f7581194382ce4df914e4bb487873.zip cpython-86a36b500a7f7581194382ce4df914e4bb487873.tar.gz cpython-86a36b500a7f7581194382ce4df914e4bb487873.tar.bz2 |
PEP 3155 / issue #13448: Qualified name for classes and functions.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/function.rst | 10 | ||||
-rw-r--r-- | Doc/data/refcounts.dat | 5 | ||||
-rw-r--r-- | Doc/glossary.rst | 18 | ||||
-rw-r--r-- | Doc/library/stdtypes.rst | 7 | ||||
-rw-r--r-- | Doc/reference/datamodel.rst | 5 |
5 files changed, 45 insertions, 0 deletions
diff --git a/Doc/c-api/function.rst b/Doc/c-api/function.rst index 31805fd..ad98322 100644 --- a/Doc/c-api/function.rst +++ b/Doc/c-api/function.rst @@ -38,6 +38,16 @@ There are a few functions specific to Python functions. object, the argument defaults and closure are set to *NULL*. +.. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname) + + As :c:func:`PyFunction_New`, but also allows to set the function object's + ``__qualname__`` attribute. *qualname* should be a unicode object or NULL; + if NULL, the ``__qualname__`` attribute is set to the same value as its + ``__name__`` attribute. + + .. versionadded:: 3.3 + + .. c:function:: PyObject* PyFunction_GetCode(PyObject *op) Return the code object associated with the function object *op*. diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index c7d7bd1..a1004ad 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -465,6 +465,11 @@ PyFunction_New:PyObject*::+1: PyFunction_New:PyObject*:code:+1: PyFunction_New:PyObject*:globals:+1: +PyFunction_NewWithQualName:PyObject*::+1: +PyFunction_NewWithQualName:PyObject*:code:+1: +PyFunction_NewWithQualName:PyObject*:globals:+1: +PyFunction_NewWithQualName:PyObject*:qualname:+1: + PyFunction_SetClosure:int::: PyFunction_SetClosure:PyObject*:op:0: PyFunction_SetClosure:PyObject*:closure:+1: diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 04b3fbb..f5ca0d9 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -544,6 +544,24 @@ Glossary for piece in food: print(piece) + qualified name + A dotted name showing the "path" from a module's global scope to a + class, function or method defined in that module, as defined in + :pep:`3155`. For top-level functions and classes, the qualified name + is the same as the object's name:: + + >>> class C: + ... class D: + ... def meth(self): + ... pass + ... + >>> C.__qualname__ + 'C' + >>> C.D.__qualname__ + 'C.D' + >>> C.D.meth.__qualname__ + 'C.D.meth' + reference count The number of references to an object. When the reference count of an object drops to zero, it is deallocated. Reference counting is diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 5bb4324..ee76cd3 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2824,6 +2824,13 @@ types, where they are relevant. Some of these are not reported by the The name of the class or type. +.. attribute:: class.__qualname__ + + The :term:`qualified name` of the class or type. + + .. versionadded:: 3.3 + + .. attribute:: class.__mro__ This attribute is a tuple of classes that are considered when looking for diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index a93c09a..55fd76b 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -448,6 +448,11 @@ Callable types +-------------------------+-------------------------------+-----------+ | :attr:`__name__` | The function's name | Writable | +-------------------------+-------------------------------+-----------+ + | :attr:`__qualname__` | The function's | Writable | + | | :term:`qualified name` | | + | | | | + | | .. versionadded:: 3.3 | | + +-------------------------+-------------------------------+-----------+ | :attr:`__module__` | The name of the module the | Writable | | | function was defined in, or | | | | ``None`` if unavailable. | | |