Re: [Python-Dev] PEP 572: Assignment Expressions

2018年4月20日 14:57:45 -0700

On 2018年04月20日 12:43, Chris Angelico wrote:
> 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?
Sorry, I didn't understand. Didn't mean to imply it couldn't be used 
everywhere.
> What would these mean?
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
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.
-Mike
_______________________________________________
Python-Dev mailing list
[email protected]
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