[Python-Dev] Misc re.match() complaint
Stephen J. Turnbull
stephen at xemacs.org
Wed Jul 17 06:15:16 CEST 2013
Terry Reedy writes:
> On 7/15/2013 10:20 PM, Guido van Rossum wrote:
>
> >> Or is this something deeper, that a group *is* a new object in
> >> principle?
> >
> > No, I just think of it as returning "a string"
>
> That is exactly what the doc says it does. See my other post.
The problem is that IIUC '"a string"' is intentionally *not* referring
to the usual "str or bytes objects" (at least that's one of the
standard uses for scare quotes, to indicate an unusual usage). Either
the docstring is using "string" in a similarly ambiguous way, or else
it's incorrect under the interpretation that buffer objects are *not*
"strings", so they should be inadmissible as targets. Something
should be fixed, and I suppose it should be the return type of group().
BTW, I suggest that Terry's usage of "string" (to mean "str or bytes"
in 3.x, "unicode or str" in 2.x) be adopted, and Guido's "stringish"
be given expanded meaning, including buffer objects. Then we can say
informally that in searching and matching a target is a stringish, the
pattern is a stringish (?) or compiled re, but the group method
returns a string.
Steve
More information about the Python-Dev
mailing list