[Tutor] "=" invalid syntax ?

Xuer linuxasking at netscape.net
Mon Feb 2 01:03:56 EST 2004


print all lines of a simple file

test.py
-----------------------------------------------
#!/usr/bin/python

try:
        fi = open('test.py', 'r')
except IOError:
        print 'Can\'t open file for reading.'
        sys.exit(0)
while (line=fi.readline()):
        print line
-----------------------------------------------
then run it

$./test.py
  File "./test.py", line 8
    while (line=fi.readline()):
               ^
SyntaxError: invalid syntax

what's the problem?

thanks and regards :)




More information about the Tutor mailing list