String/Decimal issues

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Nov 10 12:10:57 EST 2007


On Sat, 10 Nov 2007 09:02:01 -0800, Mike Howarth wrote:

> Basically I'm reducing an array of prices like so:
>>> subtotal = reduce(operator.add, itemprices)

Take a look at the built in `sum()` function.

> This gives me a string of '86.00.00' which I am trying to use with decimal
> objects.

So what the heck is in `itemprices`!?

> Being relatively new to python, I'm not sure how I could round the string or
> similar. Anyone got any ideas?

You can't round strings.  Maybe that's the problem here: data types.  Are
you sure you have numbers that you are adding and not strings or something!?

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list