On Sat, Dec 7, 2019, at 01:43, Serhiy Storchaka wrote: > This is incompatible with subscripting. match[0] returns match.group(0), > not match.groups()[0].
And dict[0] returns the value whose key is 0, not the first key of the dictionary. set[0] does not work at all. there is no general guarantee of consistency between iteration and subscripting. > This idea was already discussed and was rejected as ambiguous. > > https://bugs.python.org/issue9529 > > > def __str__(self): > > return self.group(0) > > If you can use group() and groups() which return exactly what you need > why do you want to use str() and tuple()? Recall that this thread is about proposing a new redundant method for regexes, on the apparent theory that match objects are too hard to use and so people need a method that just returns a string or a tuple instead of a match object. I could just as well ask, if you can use re.search(...).group(0) why do you want re.findfirst(...)? _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4UNLYTXP5Z77FYBOF4TEPRTSL3IW5VJP/ Code of Conduct: http://python.org/psf/codeofconduct/