On Tue, Oct 7, 2008 at 4:43 PM, Mike Orr <[EMAIL PROTECTED]> wrote: > > On Tue, Oct 7, 2008 at 3:26 PM, Mike Orr <[EMAIL PROTECTED]> wrote: >> def format_size(n, binary, precision?) >> ``n`` -- the number >> ``binary`` -- true to use base 1024 and the "Gi" series. >> ``precision`` -- not sure about this >> >> But then there's the question of bits (b) vs bytes (B), and people >> wanting the whole word spelled out, etc. > > Perhaps this: > > def format_size(n, binary, suffix="B", fullname=False, precision?): > >>>> format_size(5000, False) > 5 MB >>>> format_size(5120, True, "bytes") > 5 Mibytes >>>> format_size(5000, False, "bytes", True) > 5 megabytes > > What should ``binary`` default to, or should it have a default? > That sounds really good it goes from the most simple case to the most complex. I'll set a default to binary so. As people are more familiar with Bytes than bits
def format_size(n, binary=False, suffix="B", fullname=False, precision?): >>> format_size(5000) 5 MB >>> format_size(5120, True,bytes") 5 Mibytes >>> format_size(5000, suffix="bytes", fullname=True) 5 megabytes I'm still puzzled by the name, why not format_computer_size? or format_data_size, format_size may as well be sizes of clothing. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
