Pythonese

def human_from_bytes(bytes, factor=1024., labels=['B', 'KiB', 'MiB', 'GiB',\
                                                  'TiB', 'PiB'], precision=2):
        index = 0
        while 1. * bytes / factor**index > factor and index < len(labels)-1:
                index += 1
        return ('%.*lf %s') % (precision, 1.*bytes/factor**index, labels[index])



-- 
Andrea
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a