Stefan Ram <r...@zedat.fu-berlin.de> wrote: > Chris Green <c...@isbd.net> writes: > >I went to sys.stdin but it didn't really lead me easily to the read() > >method. All I actually wanted to know was what was the type of the > >return value of the read() method which is different in Python 2 and 3. > > |>>> import sys > |>>> >>> sys.stdin.read > <built-in method read of _io.TextIOWrapper object at 0x000000000015EBA0> > |>>> help(sys.stdin.read) > |Help on built-in function read: > | > |read(size=-1, /) method of _io.TextIOWrapper instance > | Read at most n characters from stream. > | > | Read from underlying buffer until we have n characters or we hit EOF. > | If n is negative or omitted, read until EOF. > | > |>>> type(sys.stdin.read()) > |^Z > |<class 'str'> > > Note that above it's called a "method" twice and once > a "function". > > (If I would have written the body of the documentation, > I'd use "size" instead of "n" and clearly separate > effects and results, e.g., > > |EFFECTS > | > |If <size> is not negative, read from underlying buffer until > |<size> characters are read or until EOF was read. If <size> > |is negative or omitted, read until EOF. > | > |RESULT > | > |The string read, type str, excluding a possible EOF read. > Yes, I must admit I tend to forget about the 'built-in' documentation that Python has. Coming from assembler, C and C++ one doesn't expect it, so I'm afraid I tend to search the on-line Python documentation. Usually I find what I want but in this particular case I didn't. I must remember the interactive prompt!
Thanks. -- Chris Green ยท -- https://mail.python.org/mailman/listinfo/python-list