Very often I use the following construction (especially in operators):

    try:
        something
    except SomeError:
        try:
            something_else
        except AnotherError:
            try:
                something_completely_different
            except Whatever:
                return NotImplemented


I propose a construction to simplify the staircase hierarchy of exception handlers:

    try:
        something
    except SomeError try:
        something_else
    except AnotherError try:
        something_completely_different
    except Whatever:
        return NotImplemented

This would be somewhat analogous to `else if` blocks.

This pattern is very common in operator implementations. And this proposal could simplify it a bit.

haael
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/XNR5PVAFHTK5WO6P3GS2HCM7V6FPHQLH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to