[Tutor] just what does read() return?

Steven D'Aprano steve at pearwood.info
Fri Oct 1 01:48:53 CEST 2010

On Fri, 1 Oct 2010 08:49:31 am Alex Hall wrote:

> Ah-ha!!
> re.split(r"\n+", self.original)
> That did it, and my program once again runs as expected. Thanks!

There is no need to crack that tiny peanut with the 40 lb sledgehammer 
of a regular expression.

list_of_lines = string.split('\n')

Much faster, simpler, and does the job. To get rid of empty lines:

list_of_lines = filter(None, string.split('\n'))

Steven D'Aprano

More information about the Tutor mailing list