[Python-Dev] PEP 409 update [was: PEP 409 (original) (raw)
Barry Warsaw barry at python.org
Fri Feb 3 18:29:11 CET 2012
- Previous message: [Python-Dev] PEP 409 update [was: PEP 409 - final?]
- Next message: [Python-Dev] PEP 409 update [was: PEP 409 - final?]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] PEP 409 update [was: PEP 409 - final?]
- Next message: [Python-Dev] PEP 409 update [was: PEP 409 - final?]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]