I'm printing
print(f"my named tuple: {my_tuple}")
a namedtuple
that contains integers, floats, strings and lists of each of these:
MyTuple = namedtuple(
"MyTuple",
["my_int", "my_float", "my_str", "my_float_list"],
)
my_tuple = MyTuple(42, 0.712309841231, "hello world", [1.234871231231,5.98712309812,3.623412312e-2])
The output is something like
MyTuple = (my_int=42, my_float=0.712309841231, my_str="hello world", my_float_list=[1.234871231231,5.98712309812,3.623412312e-2])
Is there any way I can automatically round the floats both in- and outside lists to, say, 2 decimal digits so that these tuples don't clog up my logs as much?