[C++-sig] map of vectors with indexing suites
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Thu May 22 19:40:10 CEST 2008
> Also, I would like to have a nice __repr__ method for the map and the
> vectors but I did not find how to add easily such methods (currently, I
> create a class that inherit the std::map only to add the repr method).
You can simply .def() an unbound function implementing __repr__. The only
requirement is that the first argument of the unbound function is "self".
E.g.
void foo(your_type const& self);
class_<your_type>("your_type")
.def("foo", foo)
;
Ralf
More information about the Cplusplus-sig
mailing list