[Python-ideas] the optional "as" statement inside "if" statements

Mike Meyer mwm at mired.org
Sun Jul 1 02:48:52 CEST 2012


On Sun, 1 Jul 2012 01:06:39 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
> This proposal has been considered and rejected many times. It's not
> general enough - it *only* works for those cases where the value to be
> retained *and* the interesting condition are the same.
> 
> Consider the simple case of a value that may be either None (not
> interesting) or a number (interesting). Since the interesting values
> include "0", which evaluates as False along with None, this limited
> form of embedded assignment syntax would not help.

What Nick failed to point out is that the existing uses of "as" all
bind *specific classes of objects*, not general ones.

> Embedded assignment in C isn't that limited., but nobody has yet
> volunteered to take the radical step of proposing "(X as Y)" as a
> general embedded assignment syntax. I suggest anyone consider such an
> idea do a *lot* of research in the python-ideas archives first, though
> (as the idea has seen plenty of discussion). It is not as obviously
> flawed as the if-and-while statement only variant, but it would still
> involve being rather persuasive to make such a significant change to
> the language.

Hasn't the BDFL rejected a general embedded assignment in any case?

As a final note, reading checking the archives for your ideas will
also give you an idea of what kinds of things are and aren't accepted
(i.e. - what's "Pythonic") as well as process - including the kinds of
questions you'll be asked here - that an idea goes through before
being accepted.

      <mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the Python-ideas mailing list