On 26/06/12 23:30, Alexander Quest wrote:

My question is how does Python know to return just the part in the
parentheses and not to return the "blahblah" and the "yattayattayatta",
etc...?

If you want to know *how* Python does it you will have to read the module code (probably in C so download the source code)

... Does the
re.findall command by default ignore anything outside of the parentheses
and only return the parentheses as a grouping withing one tuple

The help() function returns:

--------------
findall(pattern, string, flags=0)
    Return a list of all non-overlapping matches in the string.

    If one or more groups are present in the pattern, return a
    list of groups; this will be a list of tuples if the pattern
    has more than one group.

    Empty matches are included in the result.
------------------

So that's what its defined to do. How it does it is another matter.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to