On 5/22/05, Raymond Hettinger <raymond.hettinger at verizon.net> wrote: > Some of the private email I've received indicates a need for a decimal > FAQ that would shorten the module's learning curve. Nice FAQ, but where we should put it? It's kinda for advanced Decimal users... > A. Some users prefer to abbreviate the constructor to just a single > letter: > > >>> D = decimal.Decimal > >>> D('1.23') + D('3.45') > Decimal("4.68") I'd add something like "However you'll note that this kind of use is in examples, not in everyday code". > >>> TWOPLACES = Decimal(10) ** -2 I always wrote it Decimal("0.01"), I think it's more clear. > A more versatile approach is to create a separate class with Decimal > objects as attributes (working in a "has-a" capacity rather than an > "is-a" capacity) and then delegating the arithmetic to the Decimal > class. Currency will use the "has-a" method, ;) . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4