Roel Schroeven wrote:
Peter Hansen wrote:
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
Only for hard drive manufacturers, perhaps.
And physicists and chemists and engineers and all other kinds of
scientists all over the world. Plus those of us in the computer world
who agree that 'kilo == 1024' is an abomination that should never have
existed and which we should get rid of as fast as possible.
Physicists and chemists (and most engineers) don't go around
talking about "kilobytes" all that often, and when they do
it's generally unimportant whether they mean 1000 or 1024.
Given the clear "units='bytes'" default above, and my restricting
my comments to "the rest of the computer world", it should be
clear I was talking about a very limited subset of the planet.
A subset, however, which has an extremely strong attachment to
1024 instead of 1000 (for very good reasons), and which is
less likely to abandon backwards compatibility and widely accept
1000 than the US is likely to adopt metric widely in the near
future...
-Peter
--
http://mail.python.org/mailman/listinfo/python-list