[Pymoney-general] Re: Currency's distrib() method
Brought to you by:
facundobatista
From: Jeff K. <jt...@ya...> - 2005-07-02 12:40:31
|
Facundo Batista wrote: > The basic idea is to distribute a Currency amount between different > parts, and being sure that you're not losing information (well, money, > ;). But we saw three methods of doing it: > >>> Currency(1).distrib(3) > [Currency("0.33"), Currency("0.33"), Currency("0.34")] This is an easily understood example of why the distrib() method will be necessary for Currency objects. It hadn't really sunk in until Raymond mentioned pymoney's missing '/' operator on python-dev. Something like the 1-into-3 example should always be prominently mentioned in the documentation, as well as the docstring for distrib(). It should probably also appear in some sort of exception message when a user tries to use division with a Currency object. It would also be useful to show for comparison a correct and efficient distrib() for Decimal objects. If the recommendation is to convert to Decimal when doing averages and other risky/lossy math, then it would be good to show the cannonical Decimal distrib() function in convenient location in the pymoney docs. A distrib() function should not be added to stdlib decimal, obviously. |