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
I'm not sure why I can't find any good discussion of this, I have been searching since yesterday.
How do you return a class object from C++ binding and use its methods in Python i.e.:
class A {
...
void foo() {
py::print("Hello world");
}
}
class B {
...
A bar() {
a = A();
// What do I return here if I want to return a and use it in Python
// return a
}
}
I want to then bind B and use it in Python
b_object = B()
a = b_object.bar()
a.foo()
How do I do this in Pybind, Nanobind or Boost Python (if the syntax for the latter is similar).
I can't use lambdas when creating the B binding. The use case is actually more complex than what I've shown here.
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not sure why I can't find any good discussion of this, I have been searching since yesterday.
How do you return a class object from C++ binding and use its methods in Python i.e.:
I want to then bind B and use it in Python
How do I do this in Pybind, Nanobind or Boost Python (if the syntax for the latter is similar).
I can't use lambdas when creating the
B
binding. The use case is actually more complex than what I've shown here.Beta Was this translation helpful? Give feedback.
All reactions