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
the pointer initially a nullptr, that is changed by other functions in my librar.
With SIP I could just do MyObject *pg; in a file to expose that pointer to Python, and it would point to the right object and could be reached from Python code.
I am trying to achieve this with Pybind11.
I can do m.def("pg", []() { return Pyro::pg; }, py::return_value_policy::reference); which works, but I need to call a function from Python to get the pointer.
However, doing m.attr("pg") = Pyro::pg; always gives med None.
Are there any good suggestions or a solution for this? Having to call a function is a workaround, but I would like to avoid it.
I have tried looking in the documentation, but I might lack the terms I am looking for.
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
-
I have in a headerfile
extern MyObject *pg;
and in a cpp-file
MyObject *pg;
the pointer initially a nullptr, that is changed by other functions in my librar.
With SIP I could just do
MyObject *pg;
in a file to expose that pointer to Python, and it would point to the right object and could be reached from Python code.I am trying to achieve this with Pybind11.
I can do
m.def("pg", []() { return Pyro::pg; }, py::return_value_policy::reference);
which works, but I need to call a function from Python to get the pointer.However, doing
m.attr("pg") = Pyro::pg;
always gives medNone
.Are there any good suggestions or a solution for this? Having to call a function is a workaround, but I would like to avoid it.
I have tried looking in the documentation, but I might lack the terms I am looking for.
Beta Was this translation helpful? Give feedback.
All reactions