[Guido] > ... > As to why you might want to use := in a function call, I could imagine > writing > > if validate(name := re.search(pattern, line).group(1)): > return name > When I was staring at my code, I never mentioned the very first plausible use I bumped into (in code I was actively working on at the time): while not probable_prime(p := randrange(lo, hi)): pass # and now `p` is likely a random prime in range I never mentioned it because I expected it would annoy people on 3(!) counts: - assigning in a function call - reducing the loop body to `pass` - using the binding long after the loop ended Indeed, for those reasons it wasn't "an obvious" win to me - or an obvious loss. So I just moved on. However, after staring at hundreds of other cases, it does strike me as "a small win" today - my brain cells have rewired to recognize more ":=" patterns at a glance. Whether that's a good thing or not I don't know, but it is a real thing ;-) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180707/a6299c32/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4