[C++-sig] formatting str of exposed type
Daniel Brake
danielthebrake at gmail.com
Thu Sep 17 23:41:27 CEST 2015
Hi Boost Python,
I would like a C++ class which I am exposing through Boost.Python
(initially,the
boost::multiprecision::mpfr_float, with expression templates turned off --
eventually a whole pile of types depending on mpfr_float) to be able to
respond to the %precision n command, for example, from ipython.
Additionally, I would like to be able to use a format spec such as
print('{0:.40}'.format(b))
to print a variable b with 40 digits of precision. Even better, I would
like to be able to put a standard formatting letter in the format string
preceding the .format call.
My best guess would be to def("format",...) as a free function for my
class_, but I also guess that this is a standard operation, and I would
rather use a standard solution. Parsing the formatting string myself
doesn't sound like much fun, and am hoping for a little insight from the
mailing list.
Thanks very much,
Daniel Brake
University of Notre Dame
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20150917/cd79a838/attachment.html>
More information about the Cplusplus-sig
mailing list