On Mon, Mar 4, 2013 at 8:22 PM, Charles Leviton <charles.levi...@gmail.com> wrote: > I have some confusion regarding when findall returns a list of strings and > when it returns a list of tuples. > Would appreciate an explanation.
If there are no groups, it returns a list of strings, where the strings are the whole match. If there is one group, it returns a list of strings, where the strings are the content of the group. Otherwise, it returns a list of tuples of strings, where the tuples contain the group contents (the same as if an individual match had its groups() method called). If you want consistency, use finditer instead of findall. http://docs.python.org/2/library/re.html#re.finditer -- Devin _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor