According to the documentation of the "g" floating-point format,
trailing zeros should be stripped from the resulting string:
"""
General format. For a given precision p >= 1, this rounds the number
to p significant digits and then formats the result in either
fixed-point format or in scientific n
> > from decimal import Decimal as D
> > x = D(1)/D(999)
> > '{:.15g}'.format(x)
> >>
> >> '0.00100100100100100'
[...]
> > I'd say it's a bug. P is 15, you've got 17 digits after the decimal place
> > and two of those are insignificant trailing zeros.
>
> Actually it's the float versio
Ian Kelly writes:
> When you specify the a precision of 15 in your format string, you're
> telling it to take the first 15 of those. It doesn't care that the
> last couple of those are zeros, because as far as it's concerned,
> those digits are significant.
OK, it's a bit surprising, but also cons
I'm wondering what happens with the exception info during object cleanup
immediately after an exception is thrown. Consider this code:
PyObject *args = PyBuild_Value("(O(O){})", name, parent);
if (!args)
return NULL;
PyObject *val = some_python_func(x, args, NULL);
Py_DECREF(args);