The finditer function returns an iterator of matching objects.
The findall function returns a list for matching strings. .
The advantage of iterators over lists is that they are memory-friendly (producing values ββonly when necessary).
The advantage of matching objects over strings is that they are universal (they give you groups, groupdict, start, end, span, etc.).
The choice that best depends on your needs. If you need a list of matching strings, then findall is fine. If you need object matching methods or if you need to save memory, then finditer is the way to go.
Hope this helps. Good luck with your project :-)
source share