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

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

    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

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()) != "":

please advise.
thank you,


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

More information about the Python-list mailing list