[Tutor] Comparing two lines of print
orbitz at ezabel.com
orbitz at ezabel.com
Wed Jun 2 04:43:12 EDT 2004
Just take the time to compare what you have with all the other elif lines.
When you hit a snag just take a deep breath and look at the code for awhile and
think about what you are trying to do.
On Wed, 02 Jun 2004 07:42:31 +0200
Bob Heasman <bobhe at telkomsa.net> wrote:
> 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
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list