[Python-Dev] Rationale for sum()'s design?
bac at OCF.Berkeley.EDU
Tue Mar 15 20:38:11 CET 2005
Nick Coghlan wrote:
> Guido van Rossum wrote:
>> On Tue, 15 Mar 2005 00:05:32 +1000, Nick Coghlan
>> <ncoghlan at iinet.net.au> wrote:
>>> ... try:
>>> ... value += first
>>> ... except TypeError:
>>> ... raise TypeError("Cannot add first element %r to initial value
>>> %r" % (first, value))
>> No, no, no! NO! Never catch a general exception like that and replace
>> it with one of your own. That can cause hours of debugging pain later
>> on when the type error is deep down in the bowels of the += operation
>> (or perhaps deep down inside something *it* invoked).
> Ouch. Obviously, I hadn't thought about that. . .
> Wasn't there a concept floating around some time ago to support
> exception chaining, so additional context information could be added to
> a thrown exception, without losing the location of the original problem?
Yes, but it didn't go anywhere. See
http://www.python.org/dev/summary/2003-06-01_2003-06-30.html#pep-317 for the
More information about the Python-Dev