monetary applications [was: Python GUI app to impress the bos s?]

Paul Boddie paul at boddie.net
Thu Sep 19 04:14:07 EDT 2002


Alex Martelli <aleax at aleax.it> wrote in message news:<mailman.1032362843.10509.python-list at python.org>...
>
> > > http://starship.python.net/crew/aahz/FixedPoint.py

[...]

> To play devil's advocate: DB-API compliant modules have long used
> mxDateTime happily, for date-time values, even though mxDateTime
> was not (and likely will never be) in the core.

Although there's that date/time PEP that will give some kind of
standard interface, thus reducing the significance of that particular
decision.

>                                                  Why is FixedPoint (or
> Decimal or some future Currency -- whatever) different from mxDateTime
> in this regard?  How come DB-API compliant modules seem not to
> even have felt any need to fish around for a type with which to
> represent NUMERIC and DECIMAL, as they did for dates and times?

It could well be that not many people do financial database
programming in Python, bizarre and unlikely as that may seem. Taking a
look at pyPgSQL, as the only database module I have installed that
actually readily documents such things (and that should tell you
something), it would seem that monetary amounts are converted to
floating point numbers - surely the first thing one would want to
avoid in manipulating financial data. Perhaps people use integers, or
perhaps other modules provide better decimal support.

> I don't know the answers, but if "help out the DB-API" is among the
> arguments you plan to muster to convince the BDFL, you might
> want to be prepared in case these questions get raised.  No, sorry,
> I won't volunteer as a paladin for this PEP -- I'll gladly help out with
> code and even drafting the PEP if need be, but this isn't really my
> own crusade...

In that case, what do you think of this module? ;-)

  http://www.boddie.org.uk/python/downloads/ScaledDecimal.py

I'll gladly release this into the public domain, but some commentary
would be nice - I fear that I may not have implemented it as well as
the "numeric gods" might like.

Paul



More information about the Python-list mailing list