Live data from Hacker News

PEP 572: Write vs. Read, Understand and Control Flow

mail.python.org

21–28 of 28 posts

Re: PEP 572: Write vs. Read, Understand and Control Flow

#21
post #19

I think this has been possible in PHP since forever and that community treats it as bad practise. Let's not repeat PHP's mistake 20 years later...

Perhaps the 20-year mistake of PHP is treating it as a bad practice?

This has been possible in functional and "expression" languages since forever, and it's considered a very good practice.

Re: PEP 572: Write vs. Read, Understand and Control Flow

#22

At least it introduces a new operator, to avoid the classic C mistake of typing "=" when you meant "==", and various ugly workarounds like Yoda conditions. This would be a huge boon for many list/dict/set comprehensions, as currently there's no way to filter on the result of a function call in the same comprehension (map + filter in one): results = [b for b in input_data if (b := f(a))] I think it's slightly unpython…

>At least it introduces a new operator, to avoid the classic C mistake of typing "=" when you meant "==", and various ugly workarounds like Yoda conditions.

Well, = and == in C are two different operators as well.

The problem is more allowing non-boolean comparisons

Re: PEP 572: Write vs. Read, Understand and Control Flow

#23
python variables are stored in locals()(read only dict)

we have "{NAME : EXPR}" for dict

just do "(NAME : EXPR)" with parenthesis

within its scope, list comp can be

results = [b for a in data if (b: f(a))]

perhaps even with c++ range based for the win

results = [win for (the: data) if (win: f(the))]

Re: PEP 572: Write vs. Read, Understand and Control Flow

#24
post #20
post #15

I'm not particularly sold on this proposal, but the examples in the OP seem like poor counterarguments; there are a lot of ways to write incomprehensible python. (Nested list comprehensions anyone?) And it's already possible to write one-liners that do too many things; I'm not convinced that this proposal would make that worse. Best to consider how this feature would actually be used, and make a judgement as to wheth…

Looks like a major improvement in readability to me...

Perhaps, before we had generators.

Re: PEP 572: Write vs. Read, Understand and Control Flow

#25

As a long-time Python user, this is one of the worst proposals I've seen. Yes, it has a potential for being useful. But its usefulness, unlike context managers and async, is very limited, implied a substantial cognitive overhead by introducing a new operator, and has a very significant potential for abuse. One of the nice things about Python is that it is highly succing while disallowing the sort of expressions that…

>It feels like accepted PEPs are slowly coming under less scrutiny and disregarding the idea of feature orthogonality and low overhead.

I have been noticing this long before. For me it was with the pep that dealt with automatic string interpolation, i think it was 498..

Re: PEP 572: Write vs. Read, Understand and Control Flow

#26
post #21
post #19

I think this has been possible in PHP since forever and that community treats it as bad practise. Let's not repeat PHP's mistake 20 years later...

Perhaps the 20-year mistake of PHP is treating it as a bad practice? This has been possible in functional and "expression" languages since forever, and it's considered a very good practice.

> This has been possible in functional and "expression" languages since forever, and it's considered a very good practice.

Really? Can you show an example?

Re: PEP 572: Write vs. Read, Understand and Control Flow

#27
post #19

I think this has been possible in PHP since forever and that community treats it as bad practise. Let's not repeat PHP's mistake 20 years later...

Yes. sadly, I think this is spot on. I started noticing this trend with PEP 498 (Php like string interpolation). One can only hope it won't ever become so bad...

Re: PEP 572: Write vs. Read, Understand and Control Flow

#28
post #20
post #15

I'm not particularly sold on this proposal, but the examples in the OP seem like poor counterarguments; there are a lot of ways to write incomprehensible python. (Nested list comprehensions anyone?) And it's already possible to write one-liners that do too many things; I'm not convinced that this proposal would make that worse. Best to consider how this feature would actually be used, and make a judgement as to wheth…

Looks like a major improvement in readability to me...

It does make that case more readable, yes -- but is it worth making the language a bit harder to learn for new developers?

Two assignment operators instead of one doesn't seem that hard to wrap my head around, but Python is used widely in education as well, and we should also pay heed to the lessons of C++ - the road to incomprehensible languages is paved with good-intentioned syntax.

Post reply on HN