[Python-Dev] Re: Decimal data type issues (original) (raw)

Batista, Facundo FBatista at uniFON.com.ar
Thu Apr 22 10:17:58 EDT 2004


[Tim Peters]

#- [Batista, Facundo] #- > Well, I think we must decide how it works #- > #- > With: #- > #- > >>> d = Decimal('12345.678') #- > >>> d #- > Decimal( (0, (1, 2, 3, 4, 5, 6, 7, 8), -3) ) #- > >>> str(d) #- > '12345.678' #- > #- > And being the syntax Decimal.round(n), we have the #- > following options: #- > #- > a) n is the quantity of relevant digits of the #- > final number (must be non negative). #- ... #- > b) n has the same behaviour that in the built in round(). #- ... #- > What option do you all like more? #- #- I like (c) best: drop round(), because it's redundant -- #- there are other #- ways to do (a) and (b) already. Perhaps (b) isn't obvious, #- so extending #- your example with what already exists: #- #- >>> dimes = Decimal.Decimal('0.1') #- >>> print d.quantize(dimes) #- 12345.7 #- >>> print d.quantize(Decimal.Decimal('1e1')) #- 1.235E+4 #- >>>

The round() method has the appealing that it could has the same name/meaning/function that the built in round().

But, the PEP is for implementing the Spec, so I'm +1 to drop round(), at least in this stage.

#- In general, we should be very reluctant to extend the spec #- at the start: #- it's complicated, subtle and exacting, and plenty of big #- brains are working #- hard on getting the spec exactly right. Alas, it's also #- still a bit of a #- moving target.

Agree, agree.

. Facundo



More information about the Python-Dev mailing list