Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Exception Reorg PEP revised yet again

James Y Knightfoom at fuhm.net
Thu Aug 11 16:57:21 CEST 2005


On Aug 9, 2005, at 7:15 PM, Raymond Hettinger wrote:> The data gathered by Jack and Steven's research indicate that the> number> of cases where TerminatingException would be useful is ZERO.  Try> not to> introduce a new builtin that no one will ever use.  Try not to add> a new> word whose only function is to replace a two-word tuple (TOOWTDI).> Try> not to unnecessarily nest the tree (FITBN).  Try not to propose> solutions to problems that don't exist (PBP).I disagree. TerminatingException is useful. For the immediate future,  I'd like to be able to write code like this (I'm assuming that  "except:" means what it means now, because changing that for Py2.5  would be insane):   try:     TerminatingException   except NameError:     # compatibility with python < 2.5     TerminatingException = (KeyboardInterrupt, SystemExit)   try:     foo....   except TerminatingException:     raise   except:     print "error message"What this gets me:  1) easy backwards compatibility with earlier pythons which still  have KeyboardInterrupt and SystemExit under Exception and don't  provide TerminatingException  2) I still catch string exceptions, in case anyone raises one  3) Forward compatibility with pythons that add more types of  terminating exceptions.James


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp