[Python-Dev] PEP 340: Else clause for block statements
Skip 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