[mochikit] Re: Formatting strings, numbers and stuff

2008-09-17 Thread Per Cederberg
The draft version of MochiKit.Format.format() and formatter() functions are now ready for testing. They are not documented much, except for my previous email in this thread. And the API shouldn't be considered stable. So I push the bits into my temporary patch repository instead: http://github.c

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-12 Thread csnyder
On Fri, Sep 12, 2008 at 1:26 PM, Bob Ippolito <[EMAIL PROTECTED]> wrote: > > d is for integers, f is for fixed point. > > 1> mochifmt:f("${0:.2f}", [1.234]). > "$1.23" > Love it. Though I finally RTFM'd and found twoDigitFloat(), so this particular case already sucks less. --~--~-~--~--

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-12 Thread Bob Ippolito
On Fri, Sep 12, 2008 at 9:01 AM, csnyder <[EMAIL PROTECTED]> wrote: > > On Wed, Sep 10, 2008 at 3:53 PM, Per Cederberg <[EMAIL PROTECTED]> wrote: > >> Suggested formatting types: >> s - Output from toString(), this is the default >> r - Output from MochiKit.Base.repr() >> b - Binary. Outputs the n

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-12 Thread csnyder
On Wed, Sep 10, 2008 at 3:53 PM, Per Cederberg <[EMAIL PROTECTED]> wrote: > Suggested formatting types: > s - Output from toString(), this is the default > r - Output from MochiKit.Base.repr() > b - Binary. Outputs the number in base 2. > c - Character. > d - Decimal Integer. Outputs the number i

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-11 Thread Arnar Birgisson
On Wed, Sep 10, 2008 at 22:54, Bob Ippolito <[EMAIL PROTECTED]> wrote: > I think we should keep deep object names, JSON data structures are > often nested a little bit and it's nice to be able to work with them > as-is without creating a new object just to flatten it out. I was about to say the s

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-10 Thread Bob Ippolito
I think we should keep deep object names, JSON data structures are often nested a little bit and it's nice to be able to work with them as-is without creating a new object just to flatten it out. As far as nested replacements go, I think we can ditch that safely. I've never really wanted to use t

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-10 Thread Per Cederberg
Thank you everyone for the interesting comments. I had a look at PEP 3101 (Python 3), the (new) Java 1.5 Formatter API and a popular sprintf implementation for JavaScript. And in the end, it seems hard to strike a good balance between readable syntax, power features and localization. Actually, I t

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-10 Thread Bob Ippolito
On Wed, Sep 10, 2008 at 5:55 AM, Per Cederberg <[EMAIL PROTECTED]> wrote: > > I guess this is a question for Bob, but others might have some clues > here also. Thus sending it to the list. > > I've recently done some Python coding and found the % string formating > there very convenient. Now, as M

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-10 Thread Jason Bunting
> Per Cederberg said: > > > Has anybody created a generic formatting function in JavaScript? Other > libraries? Or am I the only one seeing the need? I agree that something like this should be a part of MochiKit; I remember looking for this functionality a couple of years ago and was surprise

[mochikit] Re: Formatting strings, numbers and stuff

2008-09-10 Thread Arnar Birgisson
On Wed, Sep 10, 2008 at 14:55, Per Cederberg <[EMAIL PROTECTED]> wrote: > I've recently done some Python coding and found the % string formating > there very convenient. Now, as MochiKit is so inspired by Python, I > find it a bit odd that there is no generic string formatting similar > to the Pyt