A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-May/053200.html below:

[Python-Dev] PEP 340: Else clause for block statements

[Python-Dev] PEP 340: Else clause for block statements [Python-Dev] PEP 340: Else clause for block statementsSkip Montanaro skip at pobox.com
Mon May 2 15:46:31 CEST 2005
    Anders> How do I tell try/except that I really only meant to trap
    Anders> opening('file1'), but opening 'file2' is not supposed to fail so
    Anders> I want any exception from that propagated?  Better if I could
    Anders> write:

    Anders>     in opening('file1') as f1:
    Anders>         ...
    Anders>         in opening('file2') as f2:
    Anders>             ...
    Anders>     else:
    Anders>         print "file1 not available, I'll try again later"

-1.  This has the opposite meaning of the else clause in while/for
statements.

    Anders> or even

    Anders>     in opening('file1') as f1:
    Anders>         ...
    Anders>         in opening('file2') as f2:
    Anders>             ...
    Anders>     except IOError:
    Anders>         print "file1 not available, I'll try again later"

Not keen on this either, maybe just because the "in" clause isn't a "try"
clause.

Skip

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4