Skip to content
Merged
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions development-tools/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2007,8 +2007,8 @@ How to declare PyGetSetDef functions

"Getters" and "setters" are C functions that facilitate property-like access for a class.
See :c:type:`getter <PyGetSetDef>` and :c:type:`setter <PyGetSetDef>` for details.
You can use the ``@getter`` and ``@setter`` directive to generate an "impl" function for a
getter using Argument Clinic.
You can use the ``@getter`` and ``@setter`` directives to generate
"impl" functions for a getters and setters in Argument Clinic.
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated

This example --- taken from :cpy-file:`Modules/_io/textio.c` ---
shows the use of ``@getter`` and ``@setter`` in combination with
Expand Down Expand Up @@ -2055,7 +2055,10 @@ The generated glue code looks like this:

The implementation will then work the same as a Python method which is
decorated by :py:class:`property`.
Note that each of ``@getter`` and ``@setter`` should be declared in separated definitions.
.. note::

Getters and setters must be declared as separate functions.
The "value" parameter for a "setter" is added implicitly by Argument Clinic.
Comment thread
corona10 marked this conversation as resolved.
Outdated

Comment thread
corona10 marked this conversation as resolved.
.. code-block:: pycon

Expand Down