extract substring by regex from a text file

Peter Otten __peter__ at web.de
Sat Apr 17 11:05:49 CEST 2010

Alessio wrote:

> I used readlines() to read my text file, then with a for cicle I
> extract line by line the substrings I need by regular expressions

Just in case you didn't know:

    for line in instream:

looks better, uses less memory, and may be a tad faster than

    for line in instream.readlines():


More information about the Python-list mailing list