[Python-Dev] proposal: add basic money type to the standard library

M.-A. Lemburg mal@lemburg.com
Tue, 26 Feb 2002 22:06:15 +0100


Guido van Rossum wrote:
> 
> > > > I propose adding an "abstract" money base type to the standard
> > > > library, to be subclassed by real money/decimal implementations.
> > >
> > > Why do we need this?  I guess that would be Question #1...
> >
> > For databases ?! The DB API has long had a monetary or at least
> > decimal type on its plate... never got around to implementing
> > one, though :-)
> 
> I can only find one reference to money or decimal in the DB API PEP,
> and that's as a future task.  I guess that's what you mean by "on its
> plate".

Exactly :-)
 
> Since I'm not a database expert, maybe you can explain the use of this
> in more detail?  And why would we need a monetary type rather than a
> fixed-point decimal type?

A decimal would do as well, I suppose, at least in
terms of storing the raw value. The reason for trying
to come up with a monetary type is to make operations between
monetary values having two different currencies illegal. 
Coercion between two of those would always have to be 
made explicit (for obvious reasons).

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/