Re:What's Coming in Python 3.8
by linsomniac on Wednesday July 17, 2019 @07:11PM
(#20464976)
I've literally been wanting something like the walrus operator since I first started using Python in '97. Mostly for the "m = re.match(x, y); if m: do_something()" sort of syntax.
[ Parent
| on HN ]
Re:What's Coming in Python 3.8
by dual_basis on Thursday July 18, 2019 @12:47PM
(#20471621)
I mean, that isolated example doesn't really demonstrate the benefit of a walrus operator does it? You could have just written "if re.match(x, y): do_something()". If you re-used the result of computation within the if statement, I feel that would be a better example, eg. "m = re.match(x, y); if m: do_something(m)".
Re:What's Coming in Python 3.8
by linsomniac on Friday July 19, 2019 @07:26AM
(#20477686)
True enough, as you point out I would be expecting to do_something with m. :-)