Re: Bytes/File Size Format Function

2007-06-13 Thread Ben Finney
Avell Diroll <[EMAIL PROTECTED]> writes: > I have to disagree: 'mb' should stand for "milli-bit" :) Yes, you're right. My "metre-bit" was wrong. -- \ "Whenever you read a good book, it's like the author is right | `\ there, in the room talking to you, which is why I don't like to |

Re: Bytes/File Size Format Function

2007-06-13 Thread Avell Diroll
Ben Finney wrote: > The symbol for "bit" is 'b'. The symbol for "byte" is 'B'. 'kb' is > 'kilobit', i.e. 1000 bits. 'mb' is a "metre-bit", a combination of two > units. And so on. The SI units have definitions that are only muddied > by misusing them this way. I have to disagree: 'mb' should stand

Re: Bytes/File Size Format Function

2007-06-13 Thread samuraisam
Haha, you guys. Use it however you want. But trust me, if you put MiB and GiB instead of the more-common mb and gb [MB and GB] in your applications, your users will probably have a harder time understanding what you mean. -- http://mail.python.org/mailman/listinfo/python-list

Re: Bytes/File Size Format Function

2007-06-13 Thread Ben Finney
samuraisam <[EMAIL PROTECTED]> writes: > Quick file size formatting for all those seekers out there... > > import math > > def filesizeformat(bytes, precision=2): > """Returns a humanized string for a given amount of bytes""" > bytes = int(bytes) > if bytes is 0: > return '0byt

Re: Bytes/File Size Format Function

2007-06-13 Thread half . italian
On Jun 13, 12:48 am, [EMAIL PROTECTED] wrote: > On Jun 12, 8:47 pm, samuraisam <[EMAIL PROTECTED]> wrote: > > > > > Quick file size formatting for all those seekers out there... > > > import math > > > def filesizeformat(bytes, precision=2): > > """Returns a humanized string for a given amount

Re: Bytes/File Size Format Function

2007-06-13 Thread half . italian
On Jun 13, 12:48 am, [EMAIL PROTECTED] wrote: > On Jun 12, 8:47 pm, samuraisam <[EMAIL PROTECTED]> wrote: > > > > > Quick file size formatting for all those seekers out there... > > > import math > > > def filesizeformat(bytes, precision=2): > > """Returns a humanized string for a given amount

Re: Bytes/File Size Format Function

2007-06-13 Thread half . italian
On Jun 12, 8:47 pm, samuraisam <[EMAIL PROTECTED]> wrote: > Quick file size formatting for all those seekers out there... > > import math > > def filesizeformat(bytes, precision=2): > """Returns a humanized string for a given amount of bytes""" > bytes = int(bytes) > if bytes is 0: >

Re: Bytes/File Size Format Function

2007-06-13 Thread Tim Roberts
samuraisam <[EMAIL PROTECTED]> wrote: > >Quick file size formatting for all those seekers out there... > >import math > >def filesizeformat(bytes, precision=2): >"""Returns a humanized string for a given amount of bytes""" >bytes = int(bytes) >if bytes is 0: >return '0bytes' >

Re: Bytes/File Size Format Function

2007-06-12 Thread half . italian
On Jun 12, 8:47 pm, samuraisam <[EMAIL PROTECTED]> wrote: > Quick file size formatting for all those seekers out there... > > import math > > def filesizeformat(bytes, precision=2): > """Returns a humanized string for a given amount of bytes""" > bytes = int(bytes) > if bytes is 0: >

Bytes/File Size Format Function

2007-06-12 Thread samuraisam
Quick file size formatting for all those seekers out there... import math def filesizeformat(bytes, precision=2): """Returns a humanized string for a given amount of bytes""" bytes = int(bytes) if bytes is 0: return '0bytes' log = math.floor(math.log(bytes, 1024)) retu