Movatterモバイル変換
[0]ホーム
[Python-Dev] Bare except clauses in PEP 348
Scott David DanielsScott.Daniels at Acm.Org
Thu Aug 25 19:30:22 CEST 2005
Raymond Hettinger wrote:>... I propose that the transition plan be as simple as introducing> BaseException. This allows people to write code that will work on both> 2.x and 3.0. It doesn't break anything.>> The guidance for cross-version (2.5 to 3.0) code would be:>> * To catch all but terminating exceptions, write:>> except (KeyError, SystemExit):> raise> except Exception:> ...How about: except BaseException, error: if not isinstance(error, Exception): raise ...This would accommodate other invented exceptions such as"FoundConvergance(BaseException)", which is my pseudo-examplefor an exiting exception that is not properly a subclass ofeither KeyError or SystemExit. The idea is a relaxation stopswhen it doesn't move and may start generating something sillylike divide-by-zero. Not the end of an App, but the end of a Phase.--Scott David DanielsScott.Daniels at Acm.Org
More information about the Python-Devmailing list
[8]ページ先頭