A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-February/042509.html below:

[Python-Dev] Re: Syntax for "except"

[Python-Dev] Re: Syntax for "except" [Python-Dev] Re: Syntax for "except"Edward C. Jones edcjones at erols.com
Tue Feb 10 20:24:21 EST 2004
Here is a weak proposal for a generalized type of exception. Since I 
know nothing about either language design or implementation, my hope is 
to trigger some thinking by the experts.

I would like to propose a class ExceptionList which is an exception 
containing a list, It can be used in two ways. Suppose

MyError = ExceptionList( (ValueError, TypeError) )

"except MyError:"
handles MyError, ValueError, and TypeError or any exception derived from 
them. This generalizes the current "except (ValueError, TypeError):".

"raise MyError"
raises an exception that can be handled by any except clause that 
handles MyError, ValueError, or TypeError. Here is an example for this: 
Suppose I invent the exception LengthError which is raised when a 
sequence (including sys.argv) is the wrong length. It is also raised if 
a function is passed the wrong number of arguments. I have a lot of code 
which raises and/or handles ValueError or TypeError in these situations. 
MyError can handle exceptions raised by the legacy code or vice versa.

Perhaps MyError could be a class with base classes ValueError and TypeError.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4