Skip to content
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

Docs: Argument Clinic: Group guides about default values #106872

Merged
Changes from all commits
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
40 changes: 20 additions & 20 deletions Doc/howto/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -564,22 +564,6 @@ How-to guides
=============


How to use symbolic default values
----------------------------------

The default value you provide for a parameter can't be any arbitrary
expression. Currently the following are explicitly supported:

* Numeric constants (integer and float)
* String constants
* ``True``, ``False``, and ``None``
* Simple symbolic constants like ``sys.maxsize``, which must
start with the name of the module

(In the future, this may need to get even more elaborate,
to allow full expressions like ``CONSTANT - 1``.)


How to to rename C functions and variables generated by Argument Clinic
-----------------------------------------------------------------------

Expand Down Expand Up @@ -965,8 +949,8 @@ There's also special support for a default value of ``NULL``, and
for simple expressions, documented in the following sections.


How to use the ``NULL`` default value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``NULL`` default value
^^^^^^^^^^^^^^^^^^^^^^^^^^

For string and object parameters, you can set them to ``None`` to indicate
that there's no default. However, that means the C variable will be
Expand All @@ -976,8 +960,24 @@ behaves like a default value of ``None``, but the C variable is initialized
with ``NULL``.


How to use expressions as default values
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Symbolic default values
^^^^^^^^^^^^^^^^^^^^^^^

The default value you provide for a parameter can't be any arbitrary
expression. Currently the following are explicitly supported:

* Numeric constants (integer and float)
* String constants
* ``True``, ``False``, and ``None``
* Simple symbolic constants like ``sys.maxsize``, which must
start with the name of the module

(In the future, this may need to get even more elaborate,
to allow full expressions like ``CONSTANT - 1``.)


Expressions as default values
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The default value for a parameter can be more than just a literal value.
It can be an entire expression, using math operators and looking up attributes
Expand Down