slicing the end of a string in a list

John Salerno johnjsal at NOSPAMgmail.com
Thu Mar 2 23:57:16 EST 2006


Paul Rubin wrote:

> The preferred way to remove the newline is more like:
>    for line in open('C:\\switches.txt'):
>      print line.rstrip()

Interesting. So I would say:

[line.rstrip() for line in open('C:\\switches.txt')]



More information about the Python-list mailing list