[Python-ideas] Inline changes to context, or PEP572

Steven D'Aprano steve at pearwood.info
Mon May 14 08:55:28 EDT 2018


On Sat, May 12, 2018 at 08:13:01PM -0400, Juancarlo Añez wrote:
> A new thread just to suggest taking the discussion about PEP572 well beyond
> python-ideas (PyConn is good for that).
> 
> The least anyone should want is a language change that immediately gets
> tagged on the networks as "don't use", or "use only for...", etc.

*Every* feature should be tagged as "use only for ...".

Every feature has uses that it works for, and uses that are 
inappropriate. With old features, we rarely think about the bad uses.
 
(When was the last time you needed to tell someone not to use a while 
loop when a for loop over an iterable was better? Apart from beginners 
reading "Learn Python The Hard Way", I've never seen anyone do that.)

With new features, some people do nothing but think about the bad uses.


> To be honest, I'll likely be on the "don't use :=, unless" band of pundits

As we all should.

Just as we didn't run out and change every if...else block to try to 
squeeze it into a ternary if operator, or turn every for loop into a 
comprehension, so we shouldn't use binding expressions unless they make 
the code better.


> (already a filibuster). ":=" is like going back to "reduce()", which is
> almost defunct thanks to.. us!

I don't think that it is nice of you to gloat about (almost) taking away 
a useful, much-beloved functional programming idiom. For some people, 
this comes across as "I want to make your code worse".

Fortunately, reduce is alive and well in the functools module.


-- 
Steve


More information about the Python-ideas mailing list