John Millikin wrote:
> On Sat, Apr 5, 2008 at 7:01 PM, Robert Brewer <[EMAIL PROTECTED]> wrote:
> > Re: Representation of Fractional Numbers, there are two solutions. If you
> > return decimals, people using JS on the other end are going to call
> > float(d).
> > If you return floats, people not using JS on the other end are going to go
> > use a different library. I suggest the former is more acceptable than the
> > latter for a stdlib offering. Allowing the caller of parse() to choose
> > would be even better.
>
> I don't understand what you mean, here. generate ([decimal.Decimal ('1.1')])
> -> '[1.1]', so a JavaScript user calling eval() on it would get a standard
> JavaScript float object without having to call float() explicitly.
Sorry, I wasn't describing what anyone would do in Javascript. Pythonistas
receiving JSON numbers from a JS *sender*, who want Python floats, can call
float(d) if they like if you hand them a Decimal object. Annoying but easy.
People receiving JSON numbers from, say, a Python sender, can't call Decimal(f)
if you hand them a float instance, at least not reliably. So they'll either go
use some other jsonlib (bad) or start passing numbers in strings (worse).
Robert Brewr
[EMAIL PROTECTED]
_______________________________________________
Web-SIG mailing list
[email protected]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe:
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com