I have some confusion regarding when findall returns a list of strings and
when it returns a list of tuples.
Would appreciate an explanation.

I thought if I "grouped" my match string using parentheses I'd get a list
of tuples but this example below belies my expectation.

s1 = '<td>1</td><td>Michael</td><td>Jessica</td>'
>>> strlist = re.findall(r'<td>(\w{1,})',s1)
>>> strlist
['1', 'Michael', 'Jessica']
>>> strlist = re.findall(r'<td>(\d+)</td><td>(\w+)</td>\<td>(\w+)</td>', s1)
>>> strlist
[('1', 'Michael', 'Jessica')]
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to