[Python-Dev] decimal API (original) (raw)

Batista, Facundo FBatista at uniFON.com.ar
Mon Jul 5 19:48:21 CEST 2004


[Tim Peters]

#- Note that I've suggested that some trap-enable flags should be set by #- default for Python: those for invalid operation, divide by 0, and #- overflow. So, in my mind (unsullied by reality ): (a) #- conversion of a nonsense string already signals invalid-operation; #- and, (b) because the invalid-operation trap-enable flag is set by #- default in Python, it also already raises an exception.

We don't have nothing enabled by default:

import Decimal for (exc, val) in Decimal.getcontext().trapenablers.items(): print str(exc).ljust(50), val

Decimal.Underflow 0 Decimal.DivisionByZero 0 Decimal.DecimalException 0 Decimal.Clamped 0 Decimal.DivisionUndefined 0 Decimal.Inexact 0 Decimal.InvalidContext 0 Decimal.Overflow 0 Decimal.LostDigits 0 Decimal.Rounded 0 Decimal.Subnormal 0 Decimal.InvalidOperation 0 Decimal.ConversionSyntax 0 Decimal.DivisionImpossible 0

I'm +1 to enable some by default: DivisionByZero, DivisionUndefined, Overflow, InvalidOperation, ConversionSyntax and DivisionImpossible are my proposal, but it's my taste and know nothing about numbers usability...

. Facundo


Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.713 / Virus Database: 469 - Release Date: 30/06/2004



More information about the Python-Dev mailing list