[ale] Python - read in text minus "\n"

Jay Loden jloden at toughguy.net
Sat Jan 8 14:46:37 EST 2005


I have a question for any Python programmers/hackers out there.

I am reading (with popen() ) the return from a grep search.  However, using 
read()  or readlines() also reads in "\n" after every result.  Anyone know 
how I can read it in without the newlines?  

I could of course read through the list and remove the last two characters of 
every item, but before i do that I wanted to make sure there isn't a function 
that reads without including \n, \t, \r and such.  Alternatively, maybe 
someone can suggest a regex to parse it out (I don't know regular expressions 
yet). 

Thanks for any input!
-Jay



More information about the Ale mailing list