[Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

Łukasz Langa lukasz at langa.pl
Thu Apr 26 11:48:12 EDT 2018


> On Apr 25, 2018, at 11:10 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Criticising binding- 
> expressions for that reason, especially implying that we must always use 
> parens, is simply FUD.

The PEP has more examples with parentheses than without.

>> As soon as we have to wrap a part of an expression in parentheses, 
>> parsing the entire thing becomes more complex.
> 
> Unless it becomes less complex to read and understand.

You're ignoring the context of the discussion. The new parentheses are there because there's a new assignment there. That's more complex.


>> Often enough it will 
>> cause the expression to exceed whatever line length limit the codebase 
>> pledged not to exceed, causing one line to become three.
> 
> Just how often are your lines within two characters of the maximum 
> column so that adding a pair of brackets () will "often enough" put it 
> over the limit? Seems pretty unlikely to me.

Again, you're ignoring the context of the discussion. Assuming := will have spaces around it in PEP 8, this is adding *at least* 7 characters if the name of your choice is a single character.


> This sounds really like 
> picking at straws.

The entire point of the PEP is to make things "nicer". It doesn't fundamentally enable programmers to do anything they couldn't do before.

If you think demonstrating cases where the end result won't be an improvement is picking at straws, then maybe the improvement of PEP 572 is as well.

-- Ł



More information about the Python-Dev mailing list