control precision for str(obj) output?

Bo Peng bpeng at
Wed May 4 03:34:50 CEST 2005

Dear list,

I have enjoyed the convenience to output any object with str(obj) for a 
while. However, I get long output for things like str([0.0002]) in my 
output (which bothers my users more than me though). I also do not 
understand why the following is happening:

 >>> str([0.0002])
 >>> str(0.0002)

Is there any way to fix this, other than checking the type of everything 
and output with %.4f?

Many thanks in advance.

More information about the Python-list mailing list