On Fri, May 18, 2018 at 1:27 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > This raises a new issue for me w.r.t. PEP 572. The spelling of := > makes it unlikely to accidentally use in place of ==, but what about > := and = confusion? For example, say I mean to write this: > > foo(a := 42, b, c) > > but accidentally write this instead: > > foo(a = 42, b, c) > > Hopefully for many functions this would just be a TypeError > ("unexpected keyword argument"). At the same time, it's a fairly > common practice to pass a variable to a function that happens to have > the same name as the argument being passed. Has there been any > discussion of whether this is likely to be a source of confusion?
There has been. The value of it is too great to disallow it, and most style guides would recommend writing the keyword argument with no spaces around the equals sign, so there's a bit of a chance to catch the bug that way. But you're right that it is a potential bug. ChrisA -- https://mail.python.org/mailman/listinfo/python-list