[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 ;-)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com