[Python-Dev] Arguments of MatchObject in re module

Aahz aahz at pythoncraft.com
Wed May 27 14:39:55 CEST 2009


On Tue, May 26, 2009, MRAB wrote:
>
> >>> p = re.compile("foo")
> >>> help(p.match)
> Help on built-in function match:
>
> match(...)
>     match(string[, pos[, endpos]]) --> match object or None.
>     Matches zero or more characters at the beginning of the string
>
> >>> p.match(string="foo")
>
> Traceback (most recent call last):
>   File "<pyshell#8>", line 1, in <module>
>     p.match(string="foo")
> TypeError: Required argument 'pattern' (pos 1) not found
>
> The name of the first argument should be "string", yet it's "pattern".
> Does anyone know if it's anything other than a mistake? Should it be
> fixed in the next version of the re module, or are we just stuck with it
> (and should just change the docstring to match)?

Please file a report on bugs.python.org so this doesn't get lost.
Attaching a suggested patch for _sre.c would be most welcome.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles:  boring syntax, unsurprising semantics,
few automatic coercions, etc etc.  But that's one of the things I like
about it."  --Tim Peters on Python, 16 Sep 1993


More information about the Python-Dev mailing list