Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-10 Thread M.-A. Lemburg
Nick Coghlan wrote: Guido van Rossum wrote: No, the reason is that if we did this with exceptions, it would be liable to mask errors; an exception does not necessarily originate immediately with the code you invoked, it could have been raised by something else that was invoked by that code. The

Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-07 Thread Nick Coghlan
Greg Ewing wrote: Is there some reason why Context couldn't invoke the binary operator methods using binary operators, rather than calling their methods directly? I had a similar idea, but then I remembered that the whole point of invoking the methods through a specific Context is to override the

Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-04 Thread Nick Coghlan
Guido van Rossum wrote: No, the reason is that if we did this with exceptions, it would be liable to mask errors; an exception does not necessarily originate immediately with the code you invoked, it could have been raised by something else that was invoked by that code. The special value

Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-02 Thread Nick Craig-Wood
On Tue, Mar 01, 2005 at 05:55:50PM -0500, Neil Schemenauer wrote: On Tue, Mar 01, 2005 at 11:45:43PM +1000, Nick Coghlan wrote: Interesting. In that case, my other suggestion was to have raising NotImplementedError from a special method be the equivalent of returning NotImplemented (which

Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-02 Thread Nick Coghlan
Neil Schemenauer wrote: IMO, Decimal should be returning NotImplemented instead of raising TypeError. I agree, but I'm also interested in the fact that nobody commented on this before Python 2.4 went out. I read the reference page on numeric coercion more times than I care to count, and still

Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-02 Thread Michael Hudson
Nick Coghlan [EMAIL PROTECTED] writes: Neil Schemenauer wrote: IMO, Decimal should be returning NotImplemented instead of raising TypeError. I agree, but I'm also interested in the fact that nobody commented on this before Python 2.4 went out. I read the reference page on numeric coercion

[Python-Dev] Decimal returning NotImplemented (or not)

2005-03-01 Thread Nick Coghlan
A recent question on c.l.p pointed out that the 2.4 Decimal implementation raises TypeError directly for operator arguments it doesn't understand, instead of returning NotImplemented. Obviously, this creates problems for anyone trying to define a class that 'plays nicely' with Decimal (but

RE: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-01 Thread Raymond Hettinger
A recent question on c.l.p pointed out that the 2.4 Decimal implementation raises TypeError directly for operator arguments it doesn't understand, instead of returning NotImplemented. Obviously, this creates problems for anyone trying to define a class that 'plays nicely' with Decimal

Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-01 Thread Nick Coghlan
Raymond Hettinger wrote: Try to address this in a larger context than decimal. The same sort of logic is present in sets.py and in datetime objects. Interesting. In that case, my other suggestion was to have raising NotImplementedError from a special method be the equivalent of returning

Re: [Python-Dev] Decimal returning NotImplemented (or not)

2005-03-01 Thread Neil Schemenauer
On Tue, Mar 01, 2005 at 11:45:43PM +1000, Nick Coghlan wrote: Interesting. In that case, my other suggestion was to have raising NotImplementedError from a special method be the equivalent of returning NotImplemented (which makes life much easier for a class like Decimal which has an