A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-April/052810.html below:

[Python-Dev] Re: Re: switch statement

[Python-Dev] Re: Re: switch statement [Python-Dev] Re: Re: switch statementFredrik Lundh fredrik at pythonware.com
Thu Apr 21 17:22:29 CEST 2005
Michael Chermside wrote:

> There is one exception... matching strings. There we have a powerful
> means of specifying patterns (regular expressions), and a multi-way
> branch based on the content of a string is a common situation. A new
> way to write this:
> 
>    s = get_some_string_value()
>    if s == '':
>        continue;
>    elif re.match('#.*$', s):
>        handle_comment()
>    elif s == 'DEFINE':
>        handle_define()
>    elif s == 'UNDEF':
>        handle_undefine()
>    elif re.match('[A-Za-z][A-Za-z0-9]*$', s):
>        handle_identifier()
>    else:
>        syntax_error()
> 
> would be might be nice, but I can't figure out how to make it work
> more efficiently than the simple if-elif-else structure, nor an
> elegent syntax.

somewhat related:

http://mail.python.org/pipermail/python-dev/2003-April/035075.html

</F>

More information about the Python-Dev mailing list

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