Why does str.split not take keyword arguments?

后端 未结 2 1037
孤独总比滥情好
孤独总比滥情好 2020-12-05 23:05

I came across this - in my view - strange behaviour:

\"a b c\".split(maxsplit=1)
TypeError: split() takes no keyword arguments

Why does str

相关标签:
2条回答
  • 2020-12-05 23:34

    See this bug and its superseder.

    str.split() is a native function in CPython, and as such exhibits the behavior described here:

    CPython implementation detail: An implementation may provide built-in functions whose positional parameters do not have names, even if they are ‘named’ for the purpose of documentation, and which therefore cannot be supplied by keyword. In CPython, this is the case for functions implemented in C that use PyArg_ParseTuple() to parse their arguments.

    0 讨论(0)
  • 2020-12-05 23:42

    str.split is a builtin method implemented in C. Unfortunately some builtin functions/methods do not accept keyword arguments. See this bug report.

    0 讨论(0)
提交回复
热议问题