[Python-Dev] Re: Exceptional inheritance patterns
Michael Hudson
mwh at python.net
Fri Aug 6 12:16:10 CEST 2004
Holger Krekel <pyth at devel.trillke.net> writes:
> Greg Ewing wrote:
>> > My point is that I like to regard try/except as a mechanism for
>> > "out-of-band" objects. Guidos "should be shot" seems to indicate he
>> > sees try/except only useful/applicable to exception-handling.
>>
>> If the root exception class were called something else,
>> such as 'Raisable', would that make you feel better?
>
> Yes, I certainly wouldn't object. I guess this would mean 'Exception'
> would derive from Raisable because Exception itself should probably not
> go away. Hey, strings could inherit from Raisable, too! Just kidding :-)
I would like an exception class that almost exceptions except
KeyboardInterrupt, SystemExit and -- maybe -- RuntimeError and
MemoryError inherited from.
except ExceptionsButThoseNastyOnesIDontWantToCatch:
pass
? <wink>
> Then again, i think Python has a tradition of not requiring inheritance
> but just behaviour. And doesn't this whole issue only exist because
> "raise X" with X being a class and autoinstantiated is allowed?
I would say that it's more because it's useful to organize exceptional
conditions in a tree like hierarchy and inheritance is a usable way to
do this. The fact that arranging things into tree like hierarchies
*isn't* what inheritance is usually used for in Python (unlike many
other languages) is what creates the dissonance, IMHO.
> Well, anyway, let's not add too much to the current python-dev traffic
> with this issue. I think it has been brought up a couple of times
> already.
Indeed, I think someone said what I just said above in this thread
already :-)
> Hey, i have an idea: why not create a python-syntax mailing list
> (or python-hell :-) ?
I think I've suggested that before :-)
Today is the first day I remember where there are more new messages
waiting for me in python-dev than comp.lang.python!
Cheers,
mwh
--
"The future" has arrived but they forgot to update the docs.
-- R. David Murray, 9 May 2000
More information about the Python-Dev
mailing list