Proposal: Decimal literals in Python.
J. Cliff Dyer
jcd at sdf.lonestar.org
Fri Oct 26 19:17:18 EDT 2007
Matimus wrote:
>> - 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
> fitting.
>
> So...
> Decimal("12.34") -> $12.34
>
> Pros:
> - Easier to see than appended character (I think)
> - Notation is fitting when dealing with monetary values
> - Easy to remember
> Cons:
> - 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.
>
> Matt
My only problem with Decimal("12.34") is the quotation marks. It makes
it look like a string type.
Cheers,
Cliff
More information about the Python-list
mailing list