Skip to content
Snippets Groups Projects
Commit ddcd5967 authored by David Bergström's avatar David Bergström
Browse files

Add __repr__ and __str__ to Point2DI

parent 835d454e
No related branches found
No related tags found
No related merge requests found
...@@ -33,10 +33,18 @@ void define_point(py::module & m) ...@@ -33,10 +33,18 @@ void define_point(py::module & m)
return "(" + std::to_string(p.x) + ", " + std::to_string(p.y) + ")"; return "(" + std::to_string(p.x) + ", " + std::to_string(p.y) + ")";
}); });
py::class_<sc2::Point2DI>(m, "Point2DI", py::dynamic_attr()) py::class_<sc2::Point2DI>(m, "Point2DI", py::dynamic_attr())
.def(py::init<int, int>()) .def(py::init<int, int>())
.def_readwrite("x", &sc2::Point2DI::x) .def_readwrite("x", &sc2::Point2DI::x)
.def_readwrite("y", &sc2::Point2DI::y) .def_readwrite("y", &sc2::Point2DI::y)
.def(py::self == py::self) .def(py::self == py::self)
.def(py::self != py::self); .def(py::self != py::self)
.def("__repr__",
[](const sc2::Point2DI & p) {
return "<Point2D: (" + std::to_string(p.x) + ", " + std::to_string(p.y) + ")>";
})
.def("__str__",
[](const sc2::Point2DI & p) {
return "(" + std::to_string(p.x) + ", " + std::to_string(p.y) + ")";
});
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment