Is re.findall guaranteed to be "in order?"
google at mrabarnett.plus.com
Wed Jul 16 01:37:57 CEST 2008
On Jul 15, 11:07 pm, Joshua Kugler <jkug... at bigfoot.com> wrote:
> I tried looking through re.py and sre_compile.py, but I can't really see an
> answer to my question.
> Experimenting has shown me that re.findall() will return a list with the
> matches in the order it found them. Am I lucky so far, or does the
> _sre.c's logic dictate the items will be added in order found?
> (search for "pattern_findall") seems to indicate they will be added in
> order, but can someone with a better handle on Python internals (and quite
> frankly, C) confirm this?
They will be returned in order.
More information about the Python-list