You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
For the most use cases, we use
py::arg("name")to explicitly define the argument name in the binding code:which binds a Python function:
In Functions: Accepting
*argsand**kwargs:The code binds a python function:
However,
py::argsdo not allow the user defines a custom name of the*argsargument. For example, the following code:mod.def( "func", [](const py::object& a, const py::object& b, const py::args& pos_args, const py::object& c) { return py::make_tuple(a, b, pos_args, c); }, "Some function descriptions.", py::arg("a"), py::arg("b"), py::arg("c"), );binds a Python function:
while in Python REPL:
the
*pos_argshandle appears as*argsin the function signature.The handle name of
py::argsandpy::kwargsare hardcoded and are not customizable:pybind11/include/pybind11/cast.h
Lines 900 to 907 in 7c6f2f8
Beta Was this translation helpful? Give feedback.
All reactions