On Sat, Apr 21, 2018 at 2:50 AM, Mike Miller <python-...@mgmiller.net> wrote:
>
> On 2018-04-19 23:52, Chris Angelico wrote:
>>
>> And are limited to conditions that check the truthiness/falsiness of
>> the value you care about. So that works for re.match, but not for
>> anything that might return -1 (a lot of C APIs do that, so if you're
>> working with a thin wrapper, that might be all you get), and it'll
>> encourage people to use this form when "is not None" would be more
>> appropriate (setting up for a failure if ever the API returned a
>
>
> From the previously discussed code, it might look like this:
>
>     while (file.get_next_token() as token) != -1:
>         doc += token

Except that that's now a feature of expressions, NOT of the loop
construct. And then you're left with: why not permit this everywhere?

> That leaves what to do with "with".  Guess I missed the part in the
> discussion where we couldn't fit the syntax into it.  Would requiring parens
> here not work?
>
>     with (expr() as name) as conman:
>         pass
>
> This should rarely be necessary or useful, correct?  Perhaps disallow for
> now.

What would these mean?

from contextlib import closing
with open(fn) as f:
with (open(fn) as f):
with closing(urlopen(url)) as dl:
with closing(urlopen(url) as dl):
with (closing(urlopen(url)) as dl):

One of these is not like the others...

> Also the current "while" itself could be a bit simpler by making the
> expression optional and slightly less verbose:
>
>     while:
>         points = learner.get(static_hint)
>         if not points:
>            break

As an alias for "while True"? Not a lot of benefit. I'd rather do
something like this:

while "get more learners":

which at least tells the next reader that there is a condition, even
if not a coded one.

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to