Proposal: Decimal literals in Python.
J. Cliff Dyer
jcd at sdf.lonestar.org
Sat Oct 27 01:17:18 CEST 2007
>> - Traling characters at the end of a literal are already used (the L
>> for long).
> The trailing L is going away in Python 3.0. For your consideration may
> I suggest a '$' prefix. Though, I'm not sure I even support the idea
> of a decimal literal, and I'm not even sure if I support the idea of
> using a prefix '$' to identify that literal, it seems somewhat
> Decimal("12.34") -> $12.34
> - Easier to see than appended character (I think)
> - Notation is fitting when dealing with monetary values
> - Easy to remember
> - Maybe too clever for its own good. Some people may be confused to
> find out that it isn't actually a monetary type.
> I'm sure there are more...
- Too U.S. centric. Euro would be a slight improvement, as it doesn't
privilege one country, but still too region-centric. Generic currency
marker from ISO 8859-1 would be even less unnecessarily specific, but
also too obscure.
- Looks funny if you use more or fewer than 2 decimal places.
- Sacrifices clarity of meaning for brevity.
My only problem with Decimal("12.34") is the quotation marks. It makes
it look like a string type.
More information about the Python-list