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/2000-February/002033.html below:

[Python-Dev] re: LANL syntax (case/branch)

[Python-Dev] re: LANL syntax (case/branch) [Python-Dev] re: LANL syntax (case/branch)gvwilson@nevex.com gvwilson@nevex.com
Thu, 3 Feb 2000 19:08:41 -0500 (EST)
> > Greg Wilson wrote:
> > One student (a physicist who now does computer graphics) sent me:
> > 
> >         if x is:
> >             expr1, expr2:
> >                 code using x (which is either val1 or val2)
> >             expr3:
> >                 code using x (which is guaranteed to be val3)
> >             else:
> >                 code using x (which is something else)

> Ka-Ping Yee wrote:
> I like this quite a lot! One question: in that last "else" clause,
> wouldn't "x" be undefined?

(Quick flip through notes): "x is None in the else branch".

Looking at it again, it came up as part of the question "Why isn't
assignment an operator?"  The student in question was used to doing:

if (x = foo())
{
    body
}
else if (x = bar())
{
    body
}
else
{
    body
}

and wanted to have something in Python that would (a) provide more
flexibility than a C/C++ case statement, while (b) making it clear
that the alternatives really were mutually exclusive.

I think.  Or maybe not.  He talked really, really fast...

Greg




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