Scott David Daniels wrote: > Kind of fun exercise (no good for British English). > > def units(value, units='bytes'): > magnitude = abs(value) > if magnitude >= 1000: > for prefix in ['kilo mega giga tera peta ' > 'exa zetta yotta').split(): > magnitude /= 1000. > if magnitude < 1000.: > break > elif magnitude < 1: > for prefix in ('milli micro nano pico femto ' > 'atto zepto yocto'.split(): > magnitude *= 1000. > if magnitude >= 1.0: > break > if magnitude < .001: > return 'zero %s' % units > else: > prefix = '' > if value < 0: > return '-%.3f %s%s' % (magnitude, prefix, units) > return '%.3f %s%s' % (magnitude, prefix, units) > > --Scott David Daniels > [EMAIL PROTECTED]
-- http://mail.python.org/mailman/listinfo/python-list