what is wrong with this line? while (line = workfile.readline()) != "":

erudite ask at me.com
Tue May 22 11:14:41 EDT 2001


Hey,
    I'm coming from the Java world to the python world which is probably why
I'm a little confused as to why this statement doesn't work:

while (line = workfile.readline()) != "":

when I try to run it I get a :

  File "srns.py", line 38
    while (line = workfile.readline()) != "":
                ^
SyntaxError: invalid syntax

error....
the surrounding code looks like this:

def srnsReadFile(file):
    "open single file for searching and replacing w/in"
    print "srnsReadFile"
    workfile = open(file, 'rw')

    while (line = workfile.readline()) != "":
        srnsSearchReplace(line)
    workfile.close()


please advise.
thank you,

~Eruditus~

"You can't talk to a psycho like a normal human being." -- Poe 'Trigger
Happy Jack'







More information about the Python-list mailing list