Python Input from keyboard

utab umut.tabak at gmail.com
Fri Sep 22 17:50:11 EDT 2006


hi,
I could not understand why python stdin and stdout are not explained in
any of the tutorials on the net,

I want to read some input continuously from keyboard and then I would
like to process these input.

I have a code like this but getting errors, I would like to terminate
when there is an empty string in the input, why is not this easy as the
"cin" or "scanf". I had to search for even this easy operation. Is
there a way to send EOF signal to terminate input(ctrl+??????)

#!/usr/bin/env python
import sys, math       # load system and math module
x=[]
y=[]
IN=True
print 'input x and y values :   '
while IN:
        xt,yt=input()

        if (xt==' ' or yt==' '):
                print 'you have not entered x or y, quiting'
                break
        else:
                xt= float(xt);yt=float(yt)
                x.append(xt);y.append(yt)

for i in range(x):
        print x[i]




More information about the Python-list mailing list