Ben Cartwright wrote:

>   print [line[:-1] for line in open('C:\\switches.txt')]

Hmm, I just realized in my original code that I didn't escape the 
backslash. Why did it still work properly?

By the way, this whole 'one line' thing has blown me away. I wasn't 
thinking about list comprehensions when I started working on this, but 
just the fact that it can all be done in one line is amazing. I tried 
this in C# and of course I had to create a class first, and open the 
file streams, etc.  :)

And do I not need the 'r' parameter in the open function?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to