[Python-Dev] Chaining try statements: eltry? (original) (raw)

Thomas Lotze thomas at thomas-lotze.de
Sat Jul 9 15:54:17 CEST 2005


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



More information about the Python-Dev mailing list