4 ms·
IMHO walrus operator goes against the zen of python. https://www.python.org/dev/peps/pep-0572/#differences-between-assignment-expressions-and-assignment-statem
by trymas 7y ago
IMHO walrus operator goes against the zen of python.
https://www.python.org/dev/peps/pep-0572/#differences-between-assignment-expressions-and-assignment-statements https://www.python.org/dev/peps/pep-0572/#differences-betwee...
https://www.python.org/dev/peps/pep-0572/#relative-precedence-of https://www.python.org/dev/peps/pep-0572/#relative-precedenc...
Even examples of the spec shows how unintuitive and "unpythonic" this is. Explicit is better than implicit.
IMHO adding features to the language to save 1 line of code for 10% of cases when you need it (I agree that there's occasional case when walrus will save you more than 1 line) is just bloat.
I am not a big proponent of Go, because it has its own flaws, though language is indeed very simple and creators of the language try to leave it simple.
IMO Python was very readable, super simple, intuitive and should stay that way, though recent releases show that Python is giving in for the feature bloat.
EDIT:
> Try to limit use of the walrus operator to clean cases that reduce complexity and improve readability.
Facepalm.
- bouncing 7y agoI've been using Python since 1.5 and I feel like the language itself has been feature-complete for some time. In the 2.0 era, the big pain points were async and unicode; as demonstrated by, well, how painful Twisted's unicode was. ;) But now if our big paint point is assigning a variable to len(), then in two lines evaluating that variable and printing it out, Python is just trying to find stuff to add. I miss the size and simplicity of old Python. :/
- newen 7y agoYeah. I don't like this obsession that so many developers have with adding features without end. I think it's mostly so that they can have something to do; don't think about the bigger problems, just have something to do so that they can fill out their timesheets and submit it at the end of the week.
- tvelichkov 7y agoWell the zen of python also states: - Complex is better than complicated. Using the walrus operator makes the code more complex, but less complicated.
- trymas 7y agoIt also states one line before: > Simple is better than complex. I understand that nobody will force me to use this feature, but as I said before, even the spec and the write up tells how this feature is confusing and .. complex.
- tvelichkov 7y ago> It also states one line before I know and I believe there is a purpose to be exactly after that line. Writing only simple code is not enough. If you write everything in a simple manner your code will most likely be complicated, that's exactly why you have next - complex is better than complicated. I see this feature the same way as comprehensions, scary and complex at first, but once you learn it you would wish anyone would use it.
- lolsal 7y agoI vehemently disagree - these walrus vars are still in scope outside of the condition block. And on top of that, now there are special conditions for these walrus vars which are completely not obvious. Reference: https://www.python.org/dev/peps/pep-0572/#scope-of-the-target https://www.python.org/dev/peps/pep-0572/#scope-of-the-targe...