Skip to content

Embedding and extending within a C++ class ? #5188

Answered by nkr0
nyue asked this question in Q&A
Discussion options

You must be logged in to vote
  1. Before, I wrote PythonSideMyClassName. What I meant with that is how you want to address this class in your Python script. The name you write in double-quotes is how you would see it from python. If you just want the same name, that is also fine.
PYBIND11_EMBEDDED_MODULE(fast_calc, m){ pybind11::class_<MyClass>(m, "MyClass")
                                           .def(pybind11::init<>())
                                           .def("numComponents", &MyClass::numComponents); }
  1. If you want to call MyClass::compute() from python, you should add that to the list of methods exposed in the PYBIND11_EMBEDDED_MODULE. But, that doesn't make sense in this case, because MyClass::compute()

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@nyue
Comment options

@nkr0
Comment options

Answer selected by nyue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants