mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
ada2d77977
commit
f83087ce03
13 changed files with 151 additions and 121 deletions
|
@ -34,18 +34,20 @@ There are a few functions specific to Python functions.
|
|||
Return a new function object associated with the code object *code*. *globals*
|
||||
must be a dictionary with the global variables accessible to the function.
|
||||
|
||||
The function's docstring and name are retrieved from the code object. *__module__*
|
||||
The function's docstring and name are retrieved from the code object.
|
||||
:func:`~function.__module__`
|
||||
is retrieved from *globals*. The argument defaults, annotations and closure are
|
||||
set to ``NULL``. *__qualname__* is set to the same value as the code object's
|
||||
:attr:`~codeobject.co_qualname` field.
|
||||
set to ``NULL``. :attr:`~function.__qualname__` is set to the same value as
|
||||
the code object's :attr:`~codeobject.co_qualname` field.
|
||||
|
||||
|
||||
.. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname)
|
||||
|
||||
As :c:func:`PyFunction_New`, but also allows setting 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 the
|
||||
code object's :attr:`~codeobject.co_qualname` field.
|
||||
:attr:`~function.__qualname__` attribute.
|
||||
*qualname* should be a unicode object or ``NULL``;
|
||||
if ``NULL``, the :attr:`!__qualname__` attribute is set to the same value as
|
||||
the code object's :attr:`~codeobject.co_qualname` field.
|
||||
|
||||
.. versionadded:: 3.3
|
||||
|
||||
|
@ -62,11 +64,12 @@ There are a few functions specific to Python functions.
|
|||
|
||||
.. c:function:: PyObject* PyFunction_GetModule(PyObject *op)
|
||||
|
||||
Return a :term:`borrowed reference` to the *__module__* attribute of the
|
||||
function object *op*. It can be *NULL*.
|
||||
Return a :term:`borrowed reference` to the :attr:`~function.__module__`
|
||||
attribute of the :ref:`function object <user-defined-funcs>` *op*.
|
||||
It can be *NULL*.
|
||||
|
||||
This is normally a string containing the module name, but can be set to any
|
||||
other object by Python code.
|
||||
This is normally a :class:`string <str>` containing the module name,
|
||||
but can be set to any other object by Python code.
|
||||
|
||||
|
||||
.. c:function:: PyObject* PyFunction_GetDefaults(PyObject *op)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue