[Python-Dev] Call for prudence about PEP-572 (original) (raw)

Tim Peters tim.peters at gmail.com
Sat Jul 7 12:53:14 EDT 2018


[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:

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>



More information about the Python-Dev mailing list