Serhiy Storchaka added the comment:

You can use mo.groupdict().

  print('Located coordinate at (%(row)s, %(col)s)' % mo.groupdict())
  print('Located coordinate at ({row}, {col})'.format_map(mo.groupdict()))

As for len(mo), this is ambiguous, as well as indexing with integer indices. 
You suggest len(mo) be equal len(mo.groups()) and this looks reasonable to me, 
but in regex len(mo) equals to len(mo.groups())+1 (because mo[1] equals to 
mo.group(1) or mo.groups()[0]). If indexing will work only with named groups, 
it would be expected that len(mo) will be equal to len(mo.groupdict()).

----------
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett, serhiy.storchaka

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

Reply via email to