[Python-Dev] switch-based programming in Python

Paul Svensson paul@svensson.org
Mon, 12 Nov 2001 20:49:05 -0500 (EST)


On Tue, 13 Nov 2001, Greg Ewing wrote:

>Paul Svensson <paul@svensson.org>:
>
>> On Fri, 9 Nov 2001, Donald Beaudry wrote:
>
>> >    when EXPR:
>> >        in CONSTANT_TUPLE:
>> >            [suite]
>> >    else:
>> >         [suite]
>
>> you're absolutely right on the indentation of the "else".
>
>Really? To me, the else is just another branch, and should
>be on the same level as all the others.

If you ignore how you get there, it's just another branch.
But, how you get there is the greates distinction
between the "else" branch and the other branches,
and I think this should be emphasized, not ignored.

Compare how Python uses "else" not only with "if" statements,
but also with for, while, and except.

Having the "else" indented with the "when" also makes it
immediately obvious that there can't be more than one, 
and it has to go at the end.

Besides, I find it visually more appealing.

	/Paul