Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] PEP 409 update [was: PEP 409 - final?]

Yury Selivanovyselivanov.ml at gmail.com
Fri Feb 3 18:54:33 CET 2012


Funny thing, it seems like you don't get it in the same way I did notin the first place.  His example is more like:try:  try:    raise IndexError()  except:    raise CustomError() from __NoContext__except CustomError as e:  # nevermind, let's see the whole thing after all  raise e from __OupsLooksLikeINeedContextAfterAll__On 2012-02-03, at 12:29 PM, Barry Warsaw wrote:> On Feb 03, 2012, at 08:52 AM, Ethan Furman wrote:>>> Not sure I'll ever use it this way, but:>>>> try:>>  try:>>    raise IndexError()>>  except:>>    raise CustomError() from None>> except CustomError as e:>>  # nevermind, let's see the whole thing after all>>  raise e from Ellipsis>> In that context, I have to say that the last line, even if it were written>>    raise e from ...>> is certainly cute, but not very informative.  Triple-dots will be confusing> and difficult to read in documentation and code, and Ellipsis has no logical> connection to the purpose of this PEP.  So while I'm +1 on everything else in> the PEP, I'm -1 on this particular decision.>> One of the alternatives states:>>    Create a special exception class, __NoException__.>>    Rejected as possibly confusing, possibly being mistakenly raised by users,>    and not being a truly unique value as None, True, and False are.>> I think this should be revisited.  First, `__NoException__` doesn't need to be> an exception class.  Ellipsis isn't so this doesn't need to be either.  I have> no problem adding a new non-exception derived singleton to mark this.  And> while __NoException__ may be a little confusing, something like __NoCause__> reads great and can't be mistaken for a raiseable exception.>> So your example would then be:>> try:>   try:>     raise IndexError()>   except:>     raise CustomError() from None> except CustomError as e:>   # nevermind, let's see the whole thing after all>   raise e from __NoCause__>> Cheers,> -Barry> _______________________________________________> Python-Dev mailing list>Python-Dev at python.org>http://mail.python.org/mailman/listinfo/python-dev> Unsubscribe:http://mail.python.org/mailman/options/python-dev/yselivanov.ml%40gmail.com


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp