Why not FP for Money?

Carlos Ribeiro carribeiro at gmail.com
Thu Sep 23 14:52:00 EDT 2004


On 23 Sep 2004 18:10:52 GMT, Bengt Richter <bokr at oz.net> wrote:
> >>>> a = $35.72
> >>>> b = $1.73
> >>>> a+b
> >$37.45
> ...
> I'd prefer not to use up '$' for something that specialized.
> ISTM we already have a precedent with longs: i.e., an L suffix. So why not
> a D suffix for decimal literals? E.g.,
> 
>      a = 35.72D  # 35.7200D e.g. would specify greater guaranteed precision
>      b = 1.73D
>      a+b
>      37.45D

That's what is nice about $ -- it is a specialized case, and it's a
special symbol that is readily recognized by most people as associated
with money. Not that I don't like the suffix idea -- it's only that I
think that, for a novice, it's much easier to read the $ as a prefix
for money (unless he was previously exposed to Perl, regexps and stuff
- but I'm assuming that the people that need more the Money type
aren't this type of users).

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list