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

[Python-Dev] PEP 572: Assignment Expressions

[Python-Dev] PEP 572: Assignment ExpressionsMike Miller python-dev at mgmiller.net
Sun Apr 22 16:22:42 EDT 2018
On 2018-04-22 12:37, Chris Angelico wrote:
 > Kinda, except that that's not quite a match either. But mainly, the
 > comparison with 'with' and 'except' is dangerously incompatible.

Hmm, looks very close conceptually, though mechanics are different.

Dangerous feels like an exaggeration however.  I've made the argument that 
occurrences would be very rare, but if I'm wrong, the code should blow up on its 
first run.  Perhaps a sanity check could be put in?

There is a section of your PEP that argues against the "bad code could 
potentially be written" argument, and think it applies here.


 > Maybe not, but why not just use ':=' to avoid that?

Don't hate it but feels like Pascal and C and not "Pythonic."  Too many colons, 
avoiding the questions about the difference between "=" and ":=".  Expression 
first is another win.  People know how to use "as".

 > Intuitive consistency isn't enough to handle complex cases.
 > Programming languages that favour intuitive consistency end up with a
 > million special cases.

Ok, but I think we have all the tools we need here, there's just an extra place 
to stub your toe out in the weeds.

To turn the question around, are we really worried that this awkward code (or 
some variant) is about to be written?

     with (cm_obj := callable()) as enter_result_obj:
         cm_obj.write()  #  AttributeError

If not, I argue it is a theoretical problem that, if hit, blows up immediately.

-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