FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Document how to use varargs in Argument Clinic by aisk · Pull Request #1277 · python/devguide · GitHub

Repository navigation

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
Next Next commit
move up the section
  • Loading branch information
aisk committed Feb 25, 2024
commit bf96705b2c9b38443cdc2b703363bef13a75c241
40 changes: 20 additions & 20 deletions development-tools/clinic.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,26 @@ You can still use a self converter, a return converter, and specify
a *type* argument to the object converter for :c:macro:`METH_O`.


How to convert variadic arguments functions
-------------------------------------------

Some functions can be called with an arbitrary number of arguments.
These arguments will be wrapped up in a tuple.

To convert a function to accept variadic arguments,
add a ``*`` in front of the parameter name just like Python,
and the parameter should use the ``object`` converter::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What happens if I use something else? E.g., what if I want to accept an arbitrary number of ints?

Also, what type does the implementation function receive?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for the review! I have added a new paragraph to explain more about it.


/*[clinic input]
vararg_sample

foo: int
*args: object
[clinic start generated code]*/

.. versionadded:: 3.11
Comment thread
willingc marked this conversation as resolved.


How to convert ``tp_new`` and ``tp_init`` functions
---------------------------------------------------

Expand Down Expand Up @@ -2213,23 +2233,3 @@ and update your unit tests to reflect the new behaviour.
If you forget to update your input block during the alpha and beta phases,
the compiler warning will turn into a compiler error when the
release candidate phase begins.


How to convert variadic arguments functions
-------------------------------------------

Some functions can be called with an arbitrary number of arguments.
These arguments will be wrapped up in a tuple.

To convert a function to accept variadic arguments,
add a ``*`` in front of the parameter name just like Python,
and the parameter should use the ``object`` converter::

/*[clinic input]
vararg_sample

foo: int
*args: object
[clinic start generated code]*/

.. versionadded:: 3.11

Back | FazBrowse Home | New Git URL