[Python-Dev] Chaining try statements: eltry? (original) (raw)
Thomas Lotze thomas at thomas-lotze.de
Sat Jul 9 15:54:17 CEST 2005
- Previous message: [Python-Dev] Chaining try statements: eltry?
- Next message: [Python-Dev] Request to add developer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nick Coghlan wrote:
I don't think that's a good idea. What would the following monstrosity mean?:
if 0: print "Ran the if" else for item in (1, 2, 3): print item else try: print "No exception here!" except: pass else: print "Who's else is this, anyway?"
It is unambiguous. But:
The use-case of 'elif' or 'else if' to avoid nested if statements is strong, but the use cases for the ability to mix compound statements together is significantly weaker.
This is not even about use cases anymore, it's about usability. Indentation (by indicating nesting) serves well to recognize at first sight what belongs together, and what doesn't. Mixing compound statements breaks this, as it requires the reader to think about it twice, if that's even enough.
-- Thomas
- Previous message: [Python-Dev] Chaining try statements: eltry?
- Next message: [Python-Dev] Request to add developer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]