Why no 'elif' in try/except?
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Mon Jun 4 11:55:53 EDT 2001
Sun, 3 Jun 2001 22:15:23 -0700, John Roth <johnroth at ameritech.net> pisze:
> Mixing the two makes no sense. In an except clause, there is no
> result to test; in an else clause, there is. Is the elif supposed
> to execute when there are exceptions, or when there aren't?
Of course it would mean the same as 'else: if', without forcing
another level of indentation.
> If it's simply an extension to the else clause, then I suppose
> it doesn't harm anything, but it adds complexity to the language
> definition. At this point in my life, I tend to agree with Einstein -
> make everything as simple as possible, but no simpler.
Ok, so why elif exists in the first place at all? It's redundant.
It can be replaced by 'else: if' and more indents.
Answer: convenience, to avoid those indents.
I don't understand only one thing. Why it is spelled 'elif' and not
'else if'?
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
More information about the Python-list
mailing list