A completely silly question
Mike Meyer
mwm at mired.org
Fri Dec 17 19:30:21 EST 2004
David Bolen <db3l at fitlinxx.com> writes:
> Mike Meyer <mwm at mired.org> writes:
>
>> Steven Bethard <steven.bethard at gmail.com> writes:
>>
>> > Amir Dekel wrote:
>> >> What I need from the program is to wait for a single character
>> >> input, something like while(getchar()) in C. All those Python
>> >> modules don't make much sence to me...
>> >
>> > sys.stdin.read(1)
>>
>> That doesn't do what he wants, because it doesn't return until you hit
>> a newline.
>
> Well, but that's true as well for getchar() (at least in many cases of
> interactive input and line buffering), so in that respect I do think
> it's a fairly direct replacement, depending on how the OP was going to
> use getchar() in the application.
The OP said "wait for a single character input". sys.stdin.read(1)
waits for a newline.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list