You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: rsplit() takes no keyword arguments #52872
to work. This is probably a much bigger problem than just rsplit, i.e. I doubt there is a policy about whether documented parameter names need to be usable as keywords, and if not, how one finds out which keywords are supported.
This is more of a documentation issue than anything else. The fact that the argument is named "maxsplit" and accepts a default value doesn't mean it's usable as a keyword argument. It would be difficult to document a parameter without giving it a name anyway...
As a rule of thumb, methods accepting 2 parameters or less often don't accept any keyword arguments, since there's no point in doing so.
That's interesting: do we have a place where we explain how to read the doc? I mean, a place were we can provide example/explain how we write docs, so f.e.:
str.rsplit([sep[, maxsplit]])
is a description for a method that could accept 2 optional arguments, none of them keyargs or
str.encode(encoding="utf-8", errors="strict")
is a description for a method that could take 2 optional args, and they are also keyargs (yeah, I know it's kinda bad-worded, but just to give the idea).
If you think it's overkill, let's just close this bug (after all, we have all the doc written our way ;)).
The description for the function directive is at http://docs.python.org/dev/documenting/markup.html However, I’m not sure whether the doc is accurate, since there was a switch from spam([style]) to spam(style=None) some time ago, for example in r73291.
Activity
dabrahams commentedon May 5, 2010
Based on the rsplit documentation, I'd expect
'foo bar'.rsplit(maxsplit=1)
to work. This is probably a much bigger problem than just rsplit, i.e. I doubt there is a policy about whether documented parameter names need to be usable as keywords, and if not, how one finds out which keywords are supported.
pitrou commentedon May 5, 2010
This is more of a documentation issue than anything else. The fact that the argument is named "maxsplit" and accepts a default value doesn't mean it's usable as a keyword argument. It would be difficult to document a parameter without giving it a name anyway...
As a rule of thumb, methods accepting 2 parameters or less often don't accept any keyword arguments, since there's no point in doing so.
I suggest closing this issue.
sandrotosi commentedon Jan 1, 2011
That's interesting: do we have a place where we explain how to read the doc? I mean, a place were we can provide example/explain how we write docs, so f.e.:
is a description for a method that could accept 2 optional arguments, none of them keyargs or
is a description for a method that could take 2 optional args, and they are also keyargs (yeah, I know it's kinda bad-worded, but just to give the idea).
If you think it's overkill, let's just close this bug (after all, we have all the doc written our way ;)).
Cheers,
Sandro
merwok commentedon Jan 1, 2011
The description for the function directive is at http://docs.python.org/dev/documenting/markup.html However, I’m not sure whether the doc is accurate, since there was a switch from spam([style]) to spam(style=None) some time ago, for example in r73291.
Let’s continue the discussion on the other bug.