[Python-3000] Switch and static, redux

Georg Brandl g.brandl at gmx.net
Wed Jul 5 16:39:46 CEST 2006


Andrew Clover wrote:
> Guido van Rossum <guido at python.org> wrote:
> 
>> (I'm not super confident about the syntax alternatives yet.)
> 
> The switch:-without-indent business still naggingly makes me feel 
> uncomfortable.
> 
> Is this a valid no-case-switch?
> 
>    switch cake:
>    print 'hello'

There's no "no-case-switch". As I understand it, every switch must have
at least one case.

I'm not very comfortable about the no-additional-indentation-after-colon
syntax too, but I also realize that requiring two levels of indentation
for a single statement is too much.

> Here's another syntax off the top of my head - put the first case in the
> switch statement?

>    switch biscuit.type if 'digestive':
>        ...
>    elif in 'jammy_dodger', 'garibaldi':
>        ...
>    else:
>        ...

For a large switch, it's too easy to confuse this with an if-else in case
the initial switch is off-screen.

Georg



More information about the Python-3000 mailing list