A completely silly question

David Bolen db3l at fitlinxx.com
Mon Dec 20 13:51:27 EST 2004


"Fredrik Lundh" <fredrik at pythonware.com> writes:

> >> 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.
> 
> in the same same sentence, the OP also said that he wanted something like
> C's getchar().  if you guys are going to read only parts of the original post,
> you could at least try to read an entire sentence, before you start arguing...

Not even sure what's there to argue about - getchar() does do single
character input, so the OPs (full) original sentence seems plausible
to me, and his example was using it in a while loop which I took to
represent processing some input one character at a time.

In any event - I also gave a way (Windows-specific) to truly obtain
the single next character without any buffering, so just ignore any
controversy in the first part of the response if desired.

-- David



More information about the Python-list mailing list