Arent these snippets equivalent?

Chris Angelico rosuav at gmail.com
Wed Jan 23 18:29:06 EST 2013


On Thu, Jan 24, 2013 at 9:47 AM, Roy Smith <roy at panix.com> wrote:
> while getchar() as c:
>    putchar(c)
>
> That would give people (including me) the use case they're after most of
> the time (call a function, assign the return value, and test it).  It's
> way less klunky than:
>
> while True:
>    c = getchar()
>    if c:
>       break
>    putchar()
>
> It wouldn't require assignment as an expression, or braces, or any new
> keywords.

I believe this was discussed recently (on python-ideas?). It's nice in
its simplest form, but doesn't cover all possibilities. My point about
braces was that, like assignment-expressions, it's a feature that
Python will not be implementing. Fundamentally against the "push" of
the language. If you want C, you know where to get it. (There are
other options, of course; ECMAScript and Pike come to mind. But you
know what I mean.)

ChrisA



More information about the Python-list mailing list