Exception handling

Philip Swartzleonard starx at pacbell.net
Wed May 8 07:23:06 EDT 2002


Michael Hudson || Wed 08 May 2002 03:58:31a:

> Järvinen Petri <jarvin24 at lehtori.cc.tut.fi> writes:
> 
>> Hello
>> 
>> Is it possible to use dynamic binding in exception handling like in
>> C++. 
>> 
>> I mean can I catch baseclass exception in my exception handler and
>> get all the derived classes catched aswell, like
> 
> Yes.  Didn't you try it?  Although A should have Exception amongst
> it's base classes...

Should it? I've been meaning to ask, but I haven't been pythoning much 
lately so it hasn't come up again. When defining your own exception 
heirarcy, should you derive from the standard exception class or just 
start from scratch, and why? Also, what about raising things like 
strings as exceptions (which i've done in exapmle classes for CIS/DS 
projects, e.g. 'Raise "Linked list is empty, please verify with 
is_valid"' or whatever just for documention really).

Please respond in three to four pages of doublespace twelve point 
standar serif font, in a well-organized, coherent manner that displays 
your knowledge of vocabulary and termanology learned in this newsgroup, 
while remaining understandable to people who have never heard of 
exceptions or programming before. (Sorry, it's that time of year 
again... that's what my humanities paper seems to be asking of me ;_; ;)

-- 
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com



More information about the Python-list mailing list