On 5/22/05, Raymond Hettinger <[EMAIL PROTECTED]> 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/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to