Ezio Melotti added the comment:

I discussed this briefly with Serhiy on IRC and I think the repr can be 
improved.
Currently it looks like:
>>> re.compile(r'[/\\]([.]svn)').match('/.svn')
<_sre.SRE_Match object: groups=1, span=(0, 5), group0='/.svn'>

One problem is that the group count doesn't include group 0, so from the 
example repr one would expect that the info are about the 1 (and only) group in 
"groups=", whereas that is actually group 0 and there's an additional group 1 
that is not included in the repr.

A possible solution is to separate the group count from the info about group 0:
<_sre.SRE_Match object (1 group); group0='/.svn', span=(0, 5)>

To make things even less confusing we could avoid calling it group0 and use 
something like "match=", or alternatively remove the group count (doesn't the 
count depend only on the regex, and not on the string?).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17087>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to