[Python-Dev] Sort out formatting differences in decimal and float
fetchinson at googlemail.com
Sat Dec 5 15:00:34 CET 2009
> Sorry for being a curmudgeon, however...
> >>> format(Decimal(1234), '020,g')
> >>> format(Decimal(1234), '0=20,g')
> Why in the world would you ever want to insert commas as separators and not
> use them consistently?
> >>> format(Decimal('nan'), '020,g')
> ' NaN'
> >>> format(Decimal('nan'), '0=20,g')
> Why in the world would you ever want to zero pad Nan (or Inf, for that
Because you didn't know in advance that the number ending up in your
format call was a nan (or inf)?
> Stefan> The advantage of decimal is that the user has the option to
> Stefan> suppress commas. The behaviour of float is slightly easier to
> Stefan> implement in C.
> Why? If the user asked for them why would you want to suppress (some of)
Psss, psss, put it down! - http://www.cafepress.com/putitdown
More information about the Python-Dev