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/2018-April/152823.html below:

[Python-Dev] PEP 572: Assignment Expressions

[Python-Dev] PEP 572: Assignment ExpressionsChris Angelico rosuav at gmail.com
Fri Apr 20 20:15:08 EDT 2018
On Sat, Apr 21, 2018 at 8:07 AM, Mike Miller <python-dev at mgmiller.net> wrote:
> On 2018-04-20 14:59, Jelle Zijlstra wrote:
>>     In other words, the with statement would continue to require an as
>> clause
>>     outside of the parentheses.  A double name binding doesn't seem very
>> useful
>>     however.
>>
>> The with statement does not require an as clause.
>
> Sorry, more precisely a contenxt-manager object to be returned.  So perhaps
> this "with" issue may not be one at all.

That's completely different, and isn't a syntactic point. They may
bomb with AttributeError at run time, but they also may not.

> My expectations:
>
>     with open(fn) as f:                   # current behavior
>     with (open(fn) as f):                 # syntax error, missing clause
>     with closing(urlopen(url)) as dl:     # current behavior
>     with closing(urlopen(url) as dl):     # syntax error, missing clause
>     with (closing(urlopen(url)) as dl):   # syntax error, missing clause

The second and fifth could be special cased as either the same as
first and third, or as SyntaxErrors. (But which?) The fourth one is
very tricky. If 'expr as name' is allowed inside arbitrary
expressions, why shouldn't it be allowed there? The disconnect between
viable syntax and useful statements is problematic here.

ChrisA
More information about the Python-Dev mailing list

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