Re: String/Decimal issues

2007-11-10 Thread Steven D'Aprano
On Sat, 10 Nov 2007 09:02:01 -0800, Mike Howarth wrote: > Hi > > Seem to be having a bit of brainfreeze this evening. > > Basically I'm reducing an array of prices like so: >>> subtotal = reduce(operator.add, itemprices) > > This gives me a string of '86.00.00' which I am trying to use with > d

Re: String/Decimal issues

2007-11-10 Thread Ben Finney
Mike Howarth <[EMAIL PROTECTED]> writes: > Basically I'm reducing an array of prices like so: > >> subtotal = reduce(operator.add, itemprices) > > This gives me a string of '86.00.00' You haven't shown what the input is; what is the value of 'itemprices' before this line? When I use floating-po

Re: String/Decimal issues

2007-11-10 Thread Marc 'BlackJack' Rintsch
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 w

String/Decimal issues

2007-11-10 Thread Mike Howarth
larly happy with this. Additionally I can't simply convert the string to a decimal as it would be invalid given it has multiple decimal points. Being relatively new to python, I'm not sure how I could round the string or similar. Anyone got any ideas? -- View this message in context: http: