////Groomer.py
from Dog import Dog
class Groomer:
def init(self, newDogIn ):
self.NewDog = Dog(newDogIn.breed)
/////////main.cpp
include <pybind11/pybind11.h>
include <pybind11/embed.h>
include
int main()
{
pybind11::scoped_interpreter guard{};
std::string breed = "Healer";
//Create the python class
pybind11::object new_dog = pybind11::module::import("Dog");
new_dog.attr("Dog")(pybind11.cast(breed)); //Not sure if I am doing this step correctly
//Check I am creating the instance correctly
std::cout << "New Dog is: <<( new_dog.attr("Dog).attr("get_breed") ).cast()<< std::endl; // Error #1 This step doesn't work no attribute get_breed
// Create the python class to take python class dog
pybind11::object GroomerObject = pybind11::module::import("Groomer");
/////Dog.py class Dog(object): def init(self,breed_in=""): self.breed = breed_in def get_breed(self): return self.breed
////Groomer.py from Dog import Dog class Groomer: def init(self, newDogIn ): self.NewDog = Dog(newDogIn.breed)
/////////main.cpp
include <pybind11/pybind11.h>
include <pybind11/embed.h>
include
int main() { pybind11::scoped_interpreter guard{};
std::string breed = "Healer";
//Create the python class pybind11::object new_dog = pybind11::module::import("Dog");
new_dog.attr("Dog")(pybind11.cast(breed)); //Not sure if I am doing this step correctly
//Check I am creating the instance correctly std::cout << "New Dog is: <<( new_dog.attr("Dog).attr("get_breed") ).cast()<< std::endl; // Error #1 This step doesn't work no attribute get_breed
// Create the python class to take python class dog pybind11::object GroomerObject = pybind11::module::import("Groomer");
GroomerObject.attr("Groomer")(new_dog);
return 0;
}
//Error #2 : class Dog has no attribute breed