On 16/04/12 00:20, Michael Lewis wrote:

     > What is the purpose of this?

    So that you can find the section of a long string that
    first matches your regex.


Why not use re.findall() for that? It seems like re.findall() can fill
this need and I wouldn't need to use re.search()? Can you compare an
example circumstance where one would be better suited than the other?

Performance.
It's faster to find just the first occurrence.
Especially if the string is long - say several million characters.

If you only need the first one why search for all the rest?


--
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