3 ms·
I'm using walrus a lot, can't find any negative: it's clear what it does, and the code feels cleaner.
by otherme123 3y ago
I'm using walrus a lot, can't find any negative: it's clear what it does, and the code feels cleaner.
- mixmastamyk 3y agoPython already had the “as” and assignment statements so didn’t need three ways to do it. Remember the Zen? (99% of the time walrus is used in “if” or “while” with one expression, which as handles fine.) Also, along with typing contributes to the excessive “colon blow” of modern Python.
- memefrog 3y agoThere's no 'as' in Python if or while statements, only with. >>> if True as a: File "<stdin>", line 1 if True as a: ^^ SyntaxError: invalid syntax
- mixmastamyk 3y agoIndeed. Coulda been.
- michaelcampbell 3y ago> Remember the Zen? Like Django's "explicit is better than implicit... no, wait, hold my beer" magic.