06.12.19 23:21, Random832 пише:
On Fri, Dec 6, 2019, at 15:17, Serhiy Storchaka wrote:
06.12.19 19:49, Random832 пише:
If match objects are too hard to use, maybe they should be made more 
user-friendly? What about adding str and iterable semantics to match objects so 
it can be used as str(re.search(...)); tuple(re.search(...)); a, b = 
re.search(...)?

What is semantic of these operations?

Sorry, I should have been more explicit, my intent was:

def __iter__(self):
     yield from iter(self.groups())

This is incompatible with subscripting. match[0] returns match.group(0), not match.groups()[0].

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()?
_______________________________________________
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/YIMR7CBZDNOJ2CLZPJAYXXKDA3GBO2PV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to