homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients Ramchandra Apte, cvrebert, eric.smith, joncle, mark.dickinson, rhettinger, skrah, terry.reedy, zach.ware
Date 2012年08月24日.16:04:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345824282.58.0.211758782405.issue15136@psf.upfronthosting.co.za>
In-reply-to
Content
I agree with Mark's arguments. Yesterday I tried to use as_decimal() in
a small program and it did not feel natural to me. I'll probably continue
to use Decimal(f.numerator) / f.denominator.
If this goes in, I'd prefer that as_decimal() always uses a localcontext().
As the patch stands, using as_decimal() pollutes the global context flags, 
which can be quite unexpected:
>>> from fractions import Fraction as F
>>> F(1, 3).as_decimal()
Decimal('0.3333333333333333333333333333')
>>>
>>> import decimal
>>> decimal.getcontext()
Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[InvalidOperation, DivisionByZero, Overflow])
>>>
If the function takes a context argument, it might be better to move it
into the decimal module as Decimal.from_fraction(context).
So I'm -1/7 on as_decimal(), but +1 for the __format__() method.
History
Date User Action Args
2012年08月24日 16:04:42skrahsetrecipients: + skrah, rhettinger, terry.reedy, mark.dickinson, eric.smith, cvrebert, joncle, Ramchandra Apte, zach.ware
2012年08月24日 16:04:42skrahsetmessageid: <1345824282.58.0.211758782405.issue15136@psf.upfronthosting.co.za>
2012年08月24日 16:04:41skrahlinkissue15136 messages
2012年08月24日 16:04:41skrahcreate

AltStyle によって変換されたページ (->オリジナル) /