Fyi, I found the answer ( at least one that still works )
 
def PrintThread(myThread):
    while myThread.isAlive() == True:
        line = p.stdout.readline()[:-1]
        if line == "":
                continue
        if line == '\0':
                break
        print line
 
Dave.
----- Original Message -----
Sent: Wednesday, March 09, 2005 12:24 AM
Subject: read() / readline() / readlines()

Hello!
    would someone know a method that allows
    to read line delimited by "\n" instead of trapping "\0" like
    readlines does?
 
I have to write my own while loop to do this.
 
    while myThread.isAlive() == True:
        myChar = p.stdout.read(1)
        if myChar == '\0':
            print "Found EOF, exiting!"
            break
        myStr = myStr + myChar
        if myChar == '\n':
                print myStr
                myStr = ""
                continue
 
is there a more elegant way to do this?
tx
Dave.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to