Raymond Hettinger wrote:
>>Py> decimal.Decimal("a", context)
>>Decimal("NaN")
>>
>>I'm tempted to suggest deprecating the feature, and say if you want
>>invalid
>>strings to produce NaN, use the create_decimal() method of Context
>>objects.
> 
> 
> The standard does require a NaN to be produced.

In that case, I'd prefer to see the behaviour of the Decimal constructor 
(InvalidOperation exception, or NaN result) always governed by the current 
context.

If you want to use a different context (either to limit the precision, or to 
alter the way malformed strings are handled), you invoke creation via that 
context, not via the standard constructor.

> Unless something is shown to be wrong with the current implementation, I
> don't think we should be in a hurry to make a post-release change.

The fact that the BDFL (and others, me included) were at least temporarily 
confused by the ability to pass a context in to the constructor suggests there 
is an interface problem here.

The thing that appears to be confusing is that you *can* pass a context in to 
the Decimal constructor, but that context is then almost completely ignored. It 
gives me TOOWTDI concerns,  even though passing the context to the constructor 
does, in fact, differ slightly from using the create_decimal() method (the 
former does not apply the precision, as Guido discovered).

Cheers,
NIck.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to