8000 Add "how to" for the getter Argument Clinic directive. by corona10 · Pull Request #1232 · python/devguide · GitHub
[go: up one dir, main page]

Skip to content

Add "how to" for the getter Argument Clinic directive. #1232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Nov 30, 2023
Merged
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
corona10 and AlexWaygood authored Nov 30, 2023
commit a630aecea631c250bceaa2e35ff7d10c86a41731
7 changes: 4 additions & 3 deletions development-tools/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2006,11 +2006,12 @@ The generated glue code looks like this:
How to generate a getter
------------------------

"Getters" are C functions that facilitate property-like access for a type.
"Getters" are C functions that facilitate property-like access for a class.
See :c:type:`getter <PyGetSetDef>` for details.
You can use the ``@getter`` directive to generate an "impl" function for a getter.
You can use the ``@getter`` directive to generate an "impl" function for a
getter using Argument Clinic.

This example --- taken from :cpy-file:`Modules/_io/bufferedio.c` ---
This example -- taken from :cpy-file:`Modules/_io/bufferedio.c` --
shows the use of ``@getter`` in combination with
the :ref:`@critical_section <clinic-howto-critical-sections>` directive
(which achieves thread safety without causing deadlocks between threads)::
Expand Down
0