[Tutor] Comparing two lines of print
Bob Heasman
bobhe at telkomsa.net
Wed Jun 2 01:42:31 EDT 2004
First of all thanks to those who have assisted me thus far!!!!!
I am trying to write a simple program which compares a line taken from a
file with one which I have typed into a script.
Herewith the script :-
#!/usr/bin/python
# Window analyser
# To select a phrase and send a cmd to the parallel port
# print "\a"
print "\nReading one line at a time."
text_file = open("window2", "r")
print text_file.readline()
# [PORT 6 (PTCPACTOR) - 19 - UA6ADV-0] #This a is copy of the line which
# is supposed to be compared with the next line down.
if text_file.readline() == [PORT 6 (PTCPACTOR) - 19 - UA6ADV-0]
print "UA6ADV, beam heading 000 deg. Activate relay #1"
# elif phrase == "[PORT 6 (PTCPACTOR) - 19 - F3KT-0]":
# print "F3KT, beam heading 350 deg. Activate relay #2"
# elif phrase == "[PORT 6 (PTCPACTOR) - 19 - HS0ZDZ-0]":
# print "HS0ZDZ-0, beam heading 67 deg. Activate relay #3"
# else:
# print "\n\n\t\tPhrase does not match. Return to 000 deg. Relay #1"
raw_input("\n\nPress the enter key to exit.")
*******************************
When I attempt to run this script I get a syntax error:-
[root at penguin bob]# ./readfile.py
File "./readfile.py", line 14
if text_file.readline() == [PORT 6 (PTCPACTOR) - 19 - UA6ADV-0]
^
SyntaxError: invalid syntax
****************************
I just cannot figure out why this is happening. HELP.
Cheers
Bob
More information about the Tutor
mailing list