[issue17087] Improve the repr for regular expression match objects

Ezio Melotti report at bugs.python.org
Thu Jan 31 21:57:32 CET 2013


Ezio Melotti added the comment:

#13592 is indeed the issue I was thinking about, but apparently that's about _sre.SRE_Pattern, so it's not the same thing.

> Just showing group(0) should be helpful.

Often the interesting group is group(1), so showing only group(0) seems a bit arbitrary.

> And perhaps the number of groups.

If we show only group(0), this might be useful as an indication that there are(n't) other groups.

> If a string is really long, we can truncate it like reprlib does.

That's certainly an option.

FWIW I don't usually care about the start/end, and, if included, these values could be included as span=(3,12).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17087>
_______________________________________


More information about the Python-bugs-list mailing list