Message245361
The usability, learnability, and readability of match object code would be improved by giving it a more Pythonic API (inspired by ElementTree).
Given a search like:
data = 'Answer found on row 8 column 12.'
mo = re.search(r'row (?P<row>\d+) column (?P<col>\d+)', data)
We currently access results with:
print(mo.group('col'))
print(len(mo.groups())
A better way would look like this:
print(mo['col'])
print(len(mo))
This would work nicely with string formatting:
print('Located coordinate at (%(row)s, %(col)s)' % mo)
print('Located coordinate at ({row}, {col})'.format_map(mo)) |
|
Date |
User |
Action |
Args |
2015-06-15 03:47:52 | rhettinger | set | recipients:
+ rhettinger |
2015-06-15 03:47:52 | rhettinger | set | messageid: <1434340072.54.0.23336337946.issue24454@psf.upfronthosting.co.za> |
2015-06-15 03:47:52 | rhettinger | link | issue24454 messages |
2015-06-15 03:47:51 | rhettinger | create | |
|