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

Paul Boddie paul at
Fri Sep 20 05:05:38 EDT 2002

aahz at (Aahz) wrote in message news:<amcnee$c21$1 at>...
> In article <23891c90.0209190014.26c5bb9 at>,
> Paul Boddie <paul at> wrote:
> >
> >In that case, what do you think of this module? ;-)
> >
> >
> >
> >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.
> Can you clearly explain the differences between your module and
>  If not, the numeric gods probably won't accept it.  ;-)

Well, it doesn't matter so much to me whether the numeric gods accept
it or not, since I wrote it partly for my own amusement and partly to
use it in other things, but the only thing that I can think of is that
you can specify a negative "scale" in the 'get_scaled_decimal'
function and have the resulting object round to the nearest 10**n,
where n is positive. For example:

  get_scaled_decimal("270", -2) -> 300

Apart from that, it's all aesthetics and design decisions. It would be
nice if FixedPoint had a 'round' method which returns another object,
for example, but then it would be nice if I had been consistent with
the parameters to 'get_scaled_decimal' and the 'ScaledDecimal'
constructor: one uses a precision-like thing whereas the other uses an

  ScaledDecimal(1002, -1) -> 1002 * (10 ** -1) : real
                          -> 100.2 : real
  get_scaled_decimal("100.2", 1) -> 100.2 : real

I can't remember clearly enough why I didn't use FixedPoint, but it
may have been in an earlier state when I investigated it before
writing ScaledDecimal - this was around the time of the integer
division wars, I think.


More information about the Python-list mailing list