Author rhettinger
Recipients rhettinger
Date 2015-06-15.03:47:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1434340072.54.0.23336337946.issue24454@psf.upfronthosting.co.za>
In-reply-to
Content
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))
History
Date User Action Args
2015-06-15 03:47:52rhettingersetrecipients: + rhettinger
2015-06-15 03:47:52rhettingersetmessageid: <1434340072.54.0.23336337946.issue24454@psf.upfronthosting.co.za>
2015-06-15 03:47:52rhettingerlinkissue24454 messages
2015-06-15 03:47:51rhettingercreate