A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2001-November/018591.html below:

"Switching on Multiple Values", Rev 1.1

[Python-Dev] PEP 275: "Switching on Multiple Values", Rev 1.1M.-A. Lemburg mal@lemburg.com
Tue, 13 Nov 2001 11:08:07 +0100
Skip Montanaro wrote:
> 
>     mal> Syntax:
> 
>     mal>     switch EXPR:
>     mal>         case CONSTANT:
>     mal>             SUITE
>     mal>         case CONSTANT:
>     mal>             SUITE
>     mal>         ...
>     mal>         else:
>     mal>             SUITE
> 
>     mal>     (modulo indentation variations)
> 
>     mal>     The "else" part is optional. If no else part is given and none
>     mal>     of the defined cases matches, a ValueError is raised.
> 
> Hmmm...  This doesn't jive well with current if statement semantics.  I can
> write
> 
>     if x == "first":
>        dofirst()
> 
> and no ValueError is raised if x == "second".  Why should switch be any
> different?

Hmm, you may have a point there. If the programmer wants an
exception to be raised in case none of the values matches,
she can put that code into the else-clause... I'll have to 
think about this some more, but it seems that you're right.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4