while expression feature proposal

Devin Jeanpierre jeanpierreda at gmail.com
Fri Oct 26 19:19:42 EDT 2012


On Fri, Oct 26, 2012 at 2:23 AM, Chris Angelico <rosuav at gmail.com> wrote:
> while (client.spop("profile_ids") as profile_id) is not None:
>     print profile_id
>
> Why is everyone skirting around C-style assignment expressions as
> though they're simultaneously anathema and the goal? :)

Why should these two statements behave differently? :(

    with foo() as bar: bar.baz()
    with (foo() as bar): bar.baz()

I don't understand why everyone is so attached to this "as" syntax.
It's confusing because it behaves subtly differently than how it works
in "with", and it puts the variable on the wrong side of the
assignment operator.

(I've always been partial to ":=", personally.)

-- Devin



More information about the Python-list mailing list