Proposal: Decimal literals in Python.

Matimus mccredie at gmail.com
Fri Oct 26 18:46:03 EDT 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
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...

Matt





More information about the Python-list mailing list