Proposal: Decimal literals in Python.

Carl Banks pavlovevidence at gmail.com
Fri Oct 26 22:28:31 EDT 2007


On Oct 26, 7:17 pm, "J. Cliff Dyer" <j... at sdf.lonestar.org> wrote:
> 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.

FYI: The $ sign is used to denote currency in many countries; as a
rule of thumb countties that call their currency "dollars" or "pesos"
use the $.  So Mexico, Canada, Australia, much of Latin America, much
of the Pacific, not to mention countries in Africa (Zimbabwe) and Asia
(Singapore).

It's certainly less region-specific than the Euro is.


Carl Banks




More information about the Python-list mailing list