[issue9529] Make re match object iterable

2019-12-07 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch -easy resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue9529] Make re match object iterable

2019-12-06 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +easy -patch ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue9529] Make re match object iterable

2019-04-26 Thread Mark Lawrence
Change by Mark Lawrence : -- nosy: -BreamoreBoy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue9529] Make re match object iterable

2014-08-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think MizardX means that match object should be iterable. This will allow sequence unpacking. import re m = re.match(r'(\w+):(\w+)', 'qwerty:asdfgh') k, v = m k 'qwerty' v 'asdfgh' This idea looks reasonable to me. Here is simple preliminary patch

[issue9529] Make re match object iterable

2014-08-01 Thread Matthew Barnett
Matthew Barnett added the comment: Match objects have a .groups method: import re m = re.match(r'(\w+):(\w+)', 'qwerty:asdfgh') m.groups() ('qwerty', 'asdfgh') k, v = m.groups() k 'qwerty' v 'asdfgh' -- ___ Python tracker

[issue9529] Make re match object iterable

2014-08-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Yes, but the purpose of this feature is to simplify the use of finditer() in the for loop. import re for k, v in re.finditer(r(\w+):?(\w+)?, ab:cd\nef\n): ... print(k, v) ... ab cd ef None Currently you should either unpack manually: for m in

[issue9529] Make re match object iterable

2014-08-01 Thread Ezio Melotti
Ezio Melotti added the comment: See also #19536. I still think that if we do something about these issues, we should try to be compatible with the regex module. If we are going to add support for both iterability and __getitem__, they should be consistent, so that list(m) == [m[0], m[1],

[issue9529] Make re match object iterable

2014-08-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think that if the regex module will be adopted in the stdlib, not all it's feature should be included. Regex is too complicated. In particular indexing looks confusing (due to ambiguity of starting index and redundant first item in unpacking). If we will

[issue9529] Make re match object iterable

2014-08-01 Thread Ezio Melotti
Ezio Melotti added the comment: That's indeed another valid solution, even though having indexing and iterability would be convenient (assuming we can figure out a reasonable way to implement them). -- ___ Python tracker rep...@bugs.python.org

[issue9529] Make re match object iterable

2014-08-01 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: Removed file: http://bugs.python.org/file36192/re_matchobj_iterable.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9529 ___

[issue9529] Make re match object iterable

2014-08-01 Thread Mark Lawrence
Mark Lawrence added the comment: Why worry about the new regex module? It doesn't appear to be any closer to getting into the stdlib than it was when #2636 was first opened on 15th April 2008, so maybe Python 4.0? -- nosy: +BreamoreBoy ___ Python

[issue9529] Make re match object iterable

2014-08-01 Thread Ezio Melotti
Ezio Melotti added the comment: Even if it doesn't get included in the stdlib, some people might decide to switch from re to regex (or possibly vice versa) for their projects, so the closer they are the easier this will be. Another reason is that afaik the authors of the regex module made a