Thanks Devin.  now I have a better understanding of what happens.
Let me explore finditer- hearing for the first time.


On Mon, Mar 4, 2013 at 8:47 PM, Devin Jeanpierre <[email protected]>wrote:

> On Mon, Mar 4, 2013 at 8:22 PM, Charles Leviton
> <[email protected]> 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  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to