extend methods of decimal module

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Fri Feb 28 03:54:12 EST 2014


Mark H. Harris <harrismh777 <at> gmail.com> writes:

> 
> On Thursday, February 27, 2014 10:26:59 PM UTC-6, Chris Angelico wrote:
> 
> > Create Decimal values from strings, not from the str() of a float,
> > which first rounds in binary and then rounds in decimal.
> > 
> 
> Thanks Chris...  another excellent point... ok, you guys have about
convinced me (which is spooky) but,
> hey, I'm teachable...   what is the best strategy then?
> 
> If you get a chance, take a look at the  dmath.py  code on:
> 
>    https://code.google.com/p/pythondecimallibrary/ 
> 
> I got the repository working correctly for me, and the files can be viewed
on-line ...   its a long script, but
> not that hard to look through because all the functions pretty much work
the same... when you've seen one
> converging series function in python you've seen them all!
> 
> Thanks again, Chris.
> 

Hi Mark,
I quickly skimmed through your code and I don't think there is a need for
your D() function at all. I thought it was a class adding some extra
functionality to Decimal (that's because you used a capital letter for its
name), but now I realized that it's just a function returning a Decimal from
the string representation of its argument.
Since by now, I guess, we all agree that using the string representation is
the wrong approach, you can simply use Decimal instead of D() throughout
your code.
Best,
Wolfgang






More information about the Python-list mailing list