Toon Pieton wrote: > Hey all! > > My memory seem to have a horrible leak. How does one limit the amount > of decimal spaces for a float? I used to know that... > > Example: not 5.398042156, but 5.4 (if I decide to have only one place). Usually you do this during display, while you leave the actual value untouched.
>>> '%f' % 4.55 '4.550000' >>> '%.1f' % 4.55 '4.5' >>> '%.2f' % 4.55 '4.55' > > Thanks in advance! > Toon Pieton. > ------------------------------------------------------------------------ > > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
