[Python-Dev] Mixing float and Decimal -- thread reboot

Raymond Hettinger raymond.hettinger at gmail.com
Mon Mar 22 04:10:31 CET 2010


On Mar 21, 2010, at 6:24 PM, Guido van Rossum wrote:

> On Sun, Mar 21, 2010 at 4:16 PM, Raymond Hettinger
> <raymond.hettinger at gmail.com> wrote:
>> 
>> On Mar 21, 2010, at 3:59 PM, Steven D'Aprano wrote:
>> 
>>> On Mon, 22 Mar 2010 06:31:57 am Raymond Hettinger wrote:
>>>> I really like Guido's idea of a context flag to control whether
>>>> mixing of decimal and binary floats will issue a warning.
>>>> The default should be to issue the warning (because unless
>>>> you know what you're doing, it is most likely an error).
>>> 
>>> When you say "warning", do you mean warning.warn(), or an exception?
>> 
>> 
>> I'm not sure I understand your question.  I did mean warnings.warn().
>> But that does raise a catchable exception or it can be suppressed
>> through the warnings module.  It should probably be set to
>> warn no more than once.
> 
> I would hope it could use whatever mechanism is already used for other
> conditions in the decimal module such as Underflow, Inexact, Rounded
> etc. But I have to admit I don't know exactly what those do. It
> appears they can either raise an exception or call a handle() method
> on the given exception. Are you thinking of putting the warn() call
> inside that handle() method?

Yes.


Raymond


More information about the Python-Dev mailing list