[Python-Dev] Chaining try statements: eltry?
Nick Coghlan
ncoghlan at gmail.com
Sat Jul 9 09:28:53 CEST 2005
Greg Ewing wrote:
> Guido van Rossum wrote:
>
>
>>I sometimes think it was
>>a mistake to introduce elif just to save typing "else if".
>>
>>The problem with the elwhile/elfor/eltry idea
>
> > is that you're just as likely to need e.g.
>
>>a "try" in the else clause of a while-loop as another while,
>
>
> Here's an idea for Python 3000 which addresses both of
> these: Split 'elif' back up into 'else if', but also
> generalise it so that any 'else' can be followed by any
> suite-introducing statement. Then you get all possible
> combinations for free.
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?"
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.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.blogspot.com
More information about the Python-Dev
mailing list