[Python-Dev] Wrong keyword parameter name in regex pattern methods (original) (raw)
Terry Reedy tjreedy at udel.edu
Fri Jan 24 00:56:46 CET 2014
- Previous message: [Python-Dev] Wrong keyword parameter name in regex pattern methods
- Next message: [Python-Dev] Python 3 marketing document?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 1/23/2014 12:22 PM, Serhiy Storchaka wrote:
Currently there is a mismatch between documented parameter names in some methods of regex pattern object.
match(), search(), and fullmatch() (the last was added in 3.4) document first arguments as "string": match(string[, pos[, endpos]]) search(string[, pos[, endpos]]) fullmatch(string[, pos[, endpos]]) But actually they don't accept the "string" keyword parameter, by mistake it is named as "pattern" in the code. findall() and split() document first arguments as "string": findall(string[, pos[, endpos]]) -> list split(string[, maxsplit = 0]) But actually they don't accept the "string" keyword parameter, it is named as "source" in the code. The scanner() method is not documented and also has the "source" parameter. All other methods accepts the "string" argument as documented. The match object returned by match(), search(), fullmatch(), and finditer() methods and generated by the scanner, has the "string" attribute which is equivalent to the argument of these methods. Module level functions which corresponds to these methods have the "string" parameter. Due to all these facts I think that parameter names "pattern" and "source" are accidental mistakes and should be renamed to expected "string". Because this parameter is mandatory, apparently it is always used as positional parameter, and this error was not discovered long time. http://bugs.python.org/issue20283
I think we should correct the C code before we expose it more with clinic. Otherwise, help(re.x) will conflict with the re docs.
-- Terry Jan Reedy
- Previous message: [Python-Dev] Wrong keyword parameter name in regex pattern methods
- Next message: [Python-Dev] Python 3 marketing document?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]