3 ms·
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
by theptip 9y ago
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 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...
- coldtea 9y agoLooks like a major improvement in readability to me...
- tonyedgecombe 9y agoPerhaps, before we had generators.
- theptip 9y agoIt 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.