sys.stdin.read question
Grant Edwards
grante at visi.com
Tue Dec 7 17:04:54 EST 2004
On 2004-12-08, Caleb Hattingh <caleb1 at telkomsa.net> wrote:
> It runs properly in a shell (bash), but on another matter:
>
> '>>> r=sys.stdin.read(1)
> g
> '>>> r
> 'g'
> '>>> r=sys.stdin.read(5)
> 1234567890
> '>>> r
> '\n1234'
> '>>>
>
> What exactly happened to my 1234567890? I understand that I am only
> taking 5 characters, but where does the newline (\n) come from? Is that a
> remnant from when I terminated the previous 'g' input?
Exactly.
The input stream consisted of 'g\n1234567890\n'
--
Grant Edwards grante Yow! My EARS are GONE!!
at
visi.com
More information about the Python-list
mailing list