slicing the end of a string in a list

P Boy prettyboy988-google at yahoo.com
Fri Mar 3 03:34:07 EST 2006


One liners are cool. Personally however, I would not promote one liners
in Python. Python code is meant to be read. Cryptic coding is in perl's
world.

Code below is intuitive and almost a three year old would understand.

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

BTW, if the file is huge, one may want to consider using
open('c:\\switches.txt', 'rb') instead.




More information about the Python-list mailing list