Why no 'elif' in try/except?

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Jun 7 22:11:36 EDT 2001


Marcin 'Qrczak' Kowalczyk wrote:
> 
> 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.

The convenience is worth the extra complexity in
this case, because it's quite common to have long
sequences of nested if-elses, and without it you'd
quickly run out of screen width.

But I can't imagine long sequences of nested
try-except-else-ifs turning up very often...

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list