[Python-Dev] Decimal.py in sandbox
Batista, Facundo
FBatista at uniFON.com.ar
Mon Oct 27 13:46:54 EST 2003
Aahz wrote:
#- The first thing you should do is talk with Eric Price
#- (eprice at tjhsst.edu), author of the code. You don't need to
#- use SF for
#- now; CVS should be fine, but you should find out whether
#- Eric would like
#- to approve changes first.
OK, I'll mail him.
#- There's no reason you can't start with a pre-PEP now; I'd focus on
#- interface (i.e. the question of what ``Decimal(5)/3`` and
#- ``5/Decimal(3)`` should do -- my personal take at this point is that
#- both ought to fail).
Well, there's wide discussion about this when I posted the pre-PEP of Money.
The raisoning of majority is that when two operands are of different type,
the less general must be converted to the more general one:
>>> myint = 5
>>> myfloat = 3.0
>>> mywhat = myint + myfloat
>>> type(mywhat)
<type 'float'>
With this in mind, the behaviour would be:
>>> myDecimal = Decimal(5)
>>> myfloat = 3.0
>>> mywhat = myDecimal + myfloat
>>> isinstance(mywhat, float)
True
and
>>> myDecimal = Decimal(5)
>>> myint = 3
>>> mywhat = myint + myDecimal
>>> isinstance(mywhat, Decimal)
True
but I really don't know if the first behaviour should be extended to the
latter two.
Anyway, I'll post the pre-PEP and we all should see, :)
Thanks.
. Facundo
More information about the Python-Dev
mailing list