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…
PEP 572: Write vs. Read, Understand and Control Flow
11–20 of 28 posts
Re: PEP 572: Write vs. Read, Understand and Control Flow
#12What I love about Python is that it has a limited set of "symbols" I had to learn. I would have for new cryptic combinations of characters to arise with some kind of meaning. > The LONG version looks like your expressiveness is limited by the computer. It's like having to use simple words when you talk to a child, because a child is unable to understand more subtle and advanced sentences. Fantastic! Easy to understan…
"Easy to understand" doesn't mean "every individual statement should be as simple as possible". Otherwise we'd be using assembly for everything.
Re: PEP 572: Write vs. Read, Understand and Control Flow
#13At 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…
results = [b for b in (f(a) for a in input_data) if b]Re: PEP 572: Write vs. Read, Understand and Control Flow
#14At 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…
> `results = [b for b in input_data...` Did you mean `[b for a in...`?
Re: PEP 572: Write vs. Read, Understand and Control Flow
#15And 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 whether the value outweighs the cost of making the language more complicated and harder to learn.
This proposal does have some benefits - this is the best use-case I can think of:
Instead of
response = do_thing()
while response != 200:
handle_error(response)
response = do_thing()
(Which in many other languages would be a do-while)Instead we could write:
while (response := do_thing()) != 200:
handle_error(response)
That doesn't seem like a big improvement though...Re: PEP 572: Write vs. Read, Understand and Control Flow
#16As 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…
Re: PEP 572: Write vs. Read, Understand and Control Flow
#17What I love about Python is that it has a limited set of "symbols" I had to learn. I would have for new cryptic combinations of characters to arise with some kind of meaning. > The LONG version looks like your expressiveness is limited by the computer. It's like having to use simple words when you talk to a child, because a child is unable to understand more subtle and advanced sentences. Fantastic! Easy to understan…
Easy to understand code is what makes Python so great. "Easy to understand" doesn't mean "every individual statement should be as simple as possible". Otherwise we'd be using assembly for everything.
Re: PEP 572: Write vs. Read, Understand and Control Flow
#18I mean what else than the assigned value would you expect an assignment to return? Naturally Python assignment is a special concept, but in Mathematica assignment is just a function. So it seems more natural in Mathematica. I wouldn’t mind this, however it does seem like Python deliberately tries to be less functional, hiding away map/apply and such elements and recommending lay comprehensions, so it might just not fit with Python as it is now.
Re: PEP 572: Write vs. Read, Understand and Control Flow
#19Re: PEP 572: Write vs. Read, Understand and Control Flow
#20I'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…