[Python-Dev] PEP 572: Assignment Expressions (original) (raw)
Chris Angelico rosuav at gmail.com
Fri Apr 20 20:15:08 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Next message (by thread): [Python-Dev] PEP 572: Assignment Expressions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]