[C++-sig] Boost.Python and std::string subclassing
Pertti Kellomäki
pertti.kellomaki at tut.fi
Mon May 5 14:56:09 CEST 2008
The library I am wrapping creates a subclass TCEString of std::string.
Py++ generates me bindings for the subclass, but in Python the
subclass does not quite work like std::string. For example,
the Python expression
"%s.%s.%s" % (term.functionUnit().name(), term.port().name(),
term.operation().name())
returns the string
"universal_fu.OCSetting32.<TCE.tools.TCEString object at 0x81308ec>"
because term.operation().name() returns a TCEString instead of std::string.
Is there some convenient way to make the subclass work like std::string?
I know how to do it by defining a __str__ method in the Python class,
but I am hoping that there might be a simpler way to do it using
Boost.Python or Py++.
--
Pertti
More information about the Cplusplus-sig
mailing list