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
Once I "register" a function in the module I would like, from the Python side, to programmatically retrieve somehow the signature of the funcition (even via annotations).
I'll illustrate a MWE.
My C++-side code is:
#include<pybind11/pybind11.h>namespacepy= pybind11;
PYBIND11_MODULE(example, m) {
auto func = m.def(
"my_func",
[](int a, float b) {
return a + (int)b;
},
py::arg("a"),
py::arg("b")
);
}
From the Python side, the only useful attribute I see is __doc__ which actually contains the signature, strigified
Now, a solution would be to parse this string. But since this string is generated inside pybind11, I was wandering if one can somehow retrieve this information directly from the C++ side and set in a convenient attribute or global object of the module.
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.
-
Once I "register" a function in the module I would like, from the Python side, to programmatically retrieve somehow the signature of the funcition (even via annotations).
I'll illustrate a MWE.
My C++-side code is:
From the Python side, the only useful attribute I see is
__doc__which actually contains the signature, strigifiedNow, a solution would be to parse this string. But since this string is generated inside pybind11, I was wandering if one can somehow retrieve this information directly from the C++ side and set in a convenient attribute or global object of the module.
Beta Was this translation helpful? Give feedback.
All reactions