[Python-ideas] Improving Clarity of re Module
Steven D'Aprano
steve at pearwood.info
Wed Nov 27 00:09:34 CET 2013
On Tue, Nov 26, 2013 at 05:31:09PM -0500, Alex Seewald wrote:
> For a match object, m, m.group(0) is the semantics for accessing the entire
> span of the match. For newcomers to regular expressions who are not
> familiar with the concept of a 'group', the name group(0) is
> counter-intuitive. A more natural-language-esque alias to group(0), perhaps
> 'matchSpan', could reduce the time novices spend from idea to working code.
> Of course, this convenience would introduce a bit of complexity to the
> codebase, so it may or may not be worth it to add an alias to group(0).
> What do people think?
As a beginner to regexes, it is not very long ago that I was a novice to
regexes, and I can tell you that in my experience, the difference
between group(0) and matchSpan is entirely inconsequential. I was not
familiar with either the concept of "group" nor "span", in fact I had
never come across the concept of "span" in regards to regexes until I
read your email just now.
Either way, the name would be jargon I need to learn.
--
Steven
More information about the Python-ideas
mailing list