[Tutor] Communicating Between Programs Using Raw Inputs (con'd)
aditya
nauty.me04 at gmail.com
Sun Jun 19 03:55:47 CEST 2011
On Sat, Jun 18, 2011 at 9:35 PM, Jacob Bender <benderjacob44 at gmail.com>wrote:
> Dear Tutors,
>
> Alright, I'm using linux (ubuntu) and I took all of your advice and I got
> something that works and doesn't work at the same time. Here's the source
> code for my two programs called Lock and Key:
>
> *Lock.py: *
>
> password = "a"
>
> psswd_try = raw_input("What's the password? ")
>
> if psswd_try == password:
> print "correct!!!"
> raw_input()
> else:
> print "wrong"
> raw_input()
> *
> *
Why do you need to call raw_input() again? You are giving the input only
once so remove raw_input() from both if and else , that should do the work
> *Key.py*:
>
> import sys
>
> sys.stdout.write("a")
>
> In the linux terminal I ran this command(they were both in my home folder,
> so no directories were needed):
>
> python Key.py | python Lock.py
>
> And all went well except for an EOF error caused by the raw_input inside
> the "if" statement in my Lock program. However I did get it to print
> "correct", so I know sys.stdout.write() works for what I want it to, but I
> don't want the EOF error. Here's the output:
>
> Traceback (most recent call last):
> File "Lock.py", line 7, in <module>
> raw_input()
> EOFError: EOF when reading a line
>
> Please help me get rid of it because I couldn't find a sys.stdout.close()
> command or any other std command that would help.
>
> Thanks!
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
Regards
Aditya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110619/40b18044/attachment.html>
More information about the Tutor
mailing list