3 ms·
Well the zen of python also states: - Complex is better than complicated. Using the walrus operator makes the code more complex, but less complicated.
by tvelichkov 7y ago
Well 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...