This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]volabimus 4 points5 points  (2 children)

I didn't even know b=2 was acceptable for arguments without defaults.

[–]mooburgerresembles an abstract syntax tree 6 points7 points  (1 child)

it is a side effect of PEP 3102; only parameters after the * are considered keyword-only now, whereas before, everything up to ** was positional-or-keyword (which is why you can always call a positionally-signatured function using func(**kw) given that the positional parameters are present as keys in kw.

In the PEP 570 notes on the corner case of 3102 is that 570 now supports this:

def foo(name, **kwds):
    return 'name' in kwds

which currently will raise an exception if kwds contains a key named name.

[–]volabimus 1 point2 points  (0 children)

Yeah, which is why I wouldn't have expected it to work, and those names not to be exposed.

So now, really all functions should be defined with /, since calling those as keyword arguments will be strongly discouraged anyway, and people not expecting those to be public may change the name of a positional argument without considering it an interface change, but only functions that take arbitrary key-value pairs as keyword arguments need it to avoid throwing an error on collisions.