Problems with user input
Diez B. Roggisch
deetsNOSPAM at web.de
Tue Nov 9 18:44:45 EST 2004
> I want to read exactly one char from stdin, there should
> be no need to hit enter.
That's because your terminal is in canonical mode - that means that it only
reads whole lines. You can put it to non-canonical mode - one way is
described here:
http://www.ibiblio.org/obp/py4fun/lode/lode.html#auto2
Please make sure you set it back to canonical mode, or you will expirience
some strange effects.
> Why does the whitespace char appear in front of "Your input..."?
> I guess it has something to do with not causing a linebreak
> after "Input: (y/N) ", but I want no linebreak...
The print statement concats an argument list by spaces. Use this instead:
sys.stdout.write("Your input:%s\n" % input)
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list