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/152878.html below:

[Python-Dev] PEP 572: Assignment Expressions

[Python-Dev] PEP 572: Assignment ExpressionsMike Miller python-dev at mgmiller.net
Sun Apr 22 15:46:45 EDT 2018
On 2018-04-21 19:57, Chris Angelico wrote:

Thanks for being patient.

Looks like the crux of the issue is that "with … as" binds the result of the 
enter function rather than the context-manager object, as it might first appear. 
Therefore it's not compatible with how "as" is used for direct name bindings 
after "import" statements or this sub-proposal.  Additionally, "except Class as 
instance" names the instance rather than the class.

So, the "as" keyword is already operating at an intuitive level rather than 
idealistic perfection.  Three different semantics for import/with/except, 
correct?  This sub-proposal lines up with the import use, I believe.

Given that there are no use cases for using assignment-expressions in the 
import/with/except statements, and it could be documented that if one insists an 
extra set of parens could make it work:

     with (callable() as cm_obj) as enter_result_obj:
         pass

It doesn't feel like this issue should be a blocker.

TL;DR - Been feebly trying to make the argument that everyday "intuitive 
consistency" (where the expression will be used) is more important than avoiding 
theoretical problems.  I've never seen complex with/except statements in the 
wild and don't expect this feature to significantly alter that.

-Mike

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