prePEP: Money data type

Batista, Facundo FBatista at uniFON.com.ar
Mon Oct 20 20:50:14 CEST 2003


#- I could go either way.  Or rather I'd like both.  If I was doing 
#- serious accounting programming I *absolutely* would want 
#- money*0.5 to 
#- raise an exception -- I would want to be very explicit about 
#- anything 
#- that had the potential of being imprecise.  It would simply 
#- be too easy 
#- to mess this up otherwise.

I think I'll use an idea of Alex. I'll include different types of rounding,
and you can choose from they. One of this "roundings" is to raise an
exception, not round! This is particularly dangerous, because lot of math
use it, meaning:

>>> m = Money(3, 2)
>>> m
$2.00
>>> m / 3
$0.67
>>> m = Money(3, 2, round=roundException)
>>> m / 3
Here it raises an EXCEPTION!

.	Facundo





More information about the Python-list mailing list