Skip to content Skip to sidebar Skip to footer

Can't Find Any Info On Python's Read() Method (python 2.7)

I'm trying to learn Python by going through Zed Shaw's 'Learn Python the hard way' and I'm stuck at what may seem as a very trivial thing. I'm unable to find any info on the .read(

Solution 1:

read is a method on file objects. Use:

python -m pydoc file

to get the documentation for file objects. Note that this is exactly what the book told you to do, but it appears you left of the file argument.

Alternatively, ask for just the method:

python -m pydoc file.read

The official documentation, however, is far richer and useful. See the documentation on File Objects for example.


Solution 2:

Note the formatting in Exercise 15:

  1. Run pydoc file and scroll down until you see the read() command (method/function)...

This is not accidental; the command you need is right there:

python -m pydoc file
              # ^ note argument

Post a Comment for "Can't Find Any Info On Python's Read() Method (python 2.7)"