Why not FP for Money?

Peter Hansen peter at engcorp.com
Fri Sep 24 16:18:57 EDT 2004


Carlos Ribeiro wrote:
> 1) 'd' suffix:  a = 10.123d
> 2) '$ prefix:  a = $10.123
> 
> Both alternatives are clean and easy to read, even for novices. The
> 'd' suffix is closer to what Python does already for longs (the 'L'
> suffix). The dollar sign is easily recognized, even outside US, as a
> money sign (it would be better for money/fixed point, really). 

By the way, a huge -1 on using $.  Not only does it
really only mean "money" in North America, but there's
no good reason to use a symbol for money when the
concept is much more general than that.

Furthermore, the use of a leading $ on literals in
programming has a very long history in the world of
assembly language programming, where it means hexadecimal,
similar to using a trailing h ($12f7 means the same as 12F7h).

It would be a significant mistake to pick the dollar sign
merely because of the very limited association it has
with decimal values.

(Note that a trailing d was also sometimes used in
assembly, along with trailing h, o, and b, in this case
to mean "base 10".  Since that was generally the default,
the usage was rare and in any case shouldn't conflict
with the proposed use here...)

-Peter



More information about the Python-list mailing list