Error using sys.stdin.read()

Greg Jorgensen gregj at pobox.com
Tue Jan 2 04:58:29 EST 2001


IDLE connects stdin to PyShell.PyShell, and PyShell doesn't implement the
read() method. It does implement readline()... try it.

Your script will work if you run it directly instead of inside IDLE.


--
Greg Jorgensen
PDXperts
Portland, Oregon, USA
gregj at pobox.com


<curtissol at my-deja.com> wrote in message news:92rpf1$78r$1 at nnrp1.deja.com...
> Any attempt to use the attribute "read" as in:
>
> import sys
>     while 1:
>         next = sys.stdin.read()     # read a one-character string
>         if not next:                 # or an empty string at eof
>             break
>     #process "next"
>
> fails on the use of "sys.stdin.read()" with the message:
>
> "AttributeError: 'PyShell' instance has no attribute 'read' "
>
> I am using Python 2.0 on NT 4.5 on a PC. It's as if 'read' does not
> exist.






More information about the Python-list mailing list