Daniel Brake
2015-09-17 21:41:27 UTC
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
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