I have a program which deals with nested data structures where the underlying type usually ends up being a decimal. e.g.
x={'a':[1.05600000001,2.34581736481,[1.1111111112,9.999990111111]],...}
Is there a simple pythonic way to print such a variable but rounding all floats to (say) 3dp and not assuming a particular configuration of lists and dictionaries? e.g.
{'a':[1.056,2.346,[1.111,10.000],...}
I'm thinking something like
pformat(x,round=3)
or maybe
pformat(x,conversions={'float':lambda x: "%.3g" % x})
except I don't think they have this kind of functionality. Permanently rounding the underlying data is of course not an option.