[Python-Dev] prePEP: Money data type
Batista, Facundo
FBatista at uniFON.com.ar
Fri Oct 17 17:33:48 EDT 2003
#- Good, but the name seems ambiguous -- I would expect 'money'
#- to include
#- a *currency unit*, while these are just numbers. E.g.,
#- these days for me a
#- "money amount" of "1000" isn't immediately significant --
#- does it mean "old
#- liras", Euros, SEK, ...? If a clearer name (perhaps
#- Decimal?) was adopted,
#- the type's purposes would be also clearer, perhaps.
Specifically it doesn't diferenciate it. It is printed with a '$' prefix,
but that's all.
The name really is a problem. Decimal doesn't imply the different rounding.
#- > 6. About repr(). Should ``myMoney == eval(repr(myMoney))``?
#-
#- I don't see why not.
OK, should. But must?
#- > 3. Not to support strings with engineer notation (you
#- don't need this when
#- > using money).
#-
#- Actually, with certain very depreciated currencies exponent
#- notation would
#- be VERY handy to have. E.g., given than a Euro is worth
#- 1670000 Turkish
#- Liras today, you have to count zeros accurately when expressing any
#- substantial amount in Turkish Liras -- exponential notation
#- would help.
You got me. Taking note.
#- > 10. To support the built-in methods:
#-
#- I think you mean functions, not methods, in Python terminology.
#-
#- > - min, max
#- > - float, int, long (int and long are rounded by Money)
#-
#- Rounding rather than truncation seems strange to me here.
To me too. It could be truncated, and if you want to round m to cero
precision, you always can Money(m, 0).
#- > 11. To have methods that return its components. The value
#- of Money will be
#- > ``(int part) + (frac part) / (10 ** precision)``.
#- >
#- > - ``getPrecision()``: the precision
#- > - ``getFracPart()``: the fractional part (as long)
#- > - ``getIntPart()``: the int part (as long)
#-
#- Given we're talking about Python and not Java, I would
#- suggest read-only
#- accessors (like e.g. the complex type has) rather than
#- accessor methods.
#- E.g., x.precision , x.fraction and x.integer rather than
#- x.getPrecision() etc.
Nice.
#- > But when the digit at the right of that position is
#- ==5. There, if the
#- > digit at the left of that position is odd, it gets incremented,
#- > otherwise
#- > isn't::
#- >
#- > 1.125 --> 1.12
#- > 1.135 --> 1.14
#-
#- I don't think these are the rules in the European Union
#- (they're popular
#- in statistics, but, I suspect, not legally correct in
#- accounting). I can try
#- to research that, if you need me to.
Please. Because I found it in FixedPoint, and researching, think that in
Argentina that's the way banks get rounded money.
More information about the Python-Dev
mailing list