[Python] Numero to byte
Daniele Varrazzo
piro a develer.com
Mer 12 Gen 2011 12:15:56 CET
On Wed, 12 Jan 2011 12:02:57 +0100, lordkrandel <lordkrandel a gmail.com>
wrote:
> for n, label in map( lambda k: ( factor**k[0], k[1] ),
> enumerate(labels,1) ):
Forse sarebbe meglio
for i, label in enumerate(labels, 1):
n = factor ** i
...
Se leggi <http://docs.python.org/library/stdtypes.html#string-formatting>:
# Precision (optional), given as a '.' (dot) followed by the
precision. If specified as '*' (an asterisk), the actual width
is read from the next element of the tuple in values, and the value
to convert comes after the precision.
Quindi
> return ('%.' + str(precision) + 'lf %s') % (bytes * factor /
> n, label)
potrbbe essere scritto:
return ('%.*lf %s') % (precision, bytes * factor / n, label)
Tutto untested.
--
Daniele Varrazzo - Develer S.r.l.
http://www.develer.com
Maggiori informazioni sulla lista
Python