mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
rename args_kw_only to kwonly
This commit is contained in:
committed by
Wenzel Jakob
parent
be0d804523
commit
a86ac538f5
@@ -378,14 +378,14 @@ argument in a function definition:
|
||||
f(1, b=2) # good
|
||||
f(1, 2) # TypeError: f() takes 1 positional argument but 2 were given
|
||||
|
||||
Pybind11 provides a ``py::args_kw_only`` object that allows you to implement
|
||||
Pybind11 provides a ``py::kwonly`` object that allows you to implement
|
||||
the same behaviour by specifying the object between positional and keyword-only
|
||||
argument annotations when registering the function:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
m.def("f", [](int a, int b) { /* ... */ },
|
||||
py::arg("a"), py::args_kw_only(), py::arg("b"));
|
||||
py::arg("a"), py::kwonly(), py::arg("b"));
|
||||
|
||||
Note that, as in Python, you cannot combine this with a ``py::args`` argument.
|
||||
This feature does *not* require Python 3 to work.
|
||||
|
||||
Reference in New Issue
Block a user