[Tutor] Communicating Between Programs Using Raw Inputs (con'd)
Jacob Bender
benderjacob44 at gmail.com
Sat Jun 18 18:05:54 CEST 2011
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()
*
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110618/11ec35c2/attachment-0001.html>
More information about the Tutor
mailing list