I'm trying to find out what seek does in Python using powershell

46 Views Asked by At

When I search for it using this command python -m pydoc file. seek

python -m pydoc file. seek

Brings this back to me

No Python documentation found for 'file.seek'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

I have been learning Python for a short time From the book learn python the hard way There is a drill that tells me to search for file.seek using pydoc

I am trying to find an answer to help me solve my problem and I expect to find an answer here

1

There are 1 best solutions below

0
Carl_M On

For python -m pydoc file.seek to succeed, the file must be found in a search path. As the message says, Use help() to get the interactive help utility.

>>> help()

Welcome to Python 3.12's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the internet at https://docs.python.org/3.12/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help> file
No Python documentation found for 'file'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

help>

In this case the file cannot be found. That is the issue. Let's try the command on a file that can be found and contains a function that exists.

help> os.lseek
Help on built-in function lseek in os:

os.lseek = lseek(fd, position, whence, /)
    Set the position of a file descriptor.  Return the new position.

      fd
        An open file descriptor, as returned by os.open().
      position
        Position, interpreted relative to 'whence'.
      whence
        The relative position to seek from. Valid values are:
        - SEEK_SET: seek from the start of the file.
        - SEEK_CUR: seek from the current file position.
        - SEEK_END: seek from the end of the file.

    The return value is the number of bytes relative to the beginning of the file.

help> q

So, for python -m pydoc os.lseek the module and function that we are looking for help on must exist.

C:\Users\ctynd>python -m pydoc os.lseek
Help on built-in function lseek in os:

os.lseek = lseek(fd, position, whence, /)
    Set the position of a file descriptor.  Return the new position.

      fd
        An open file descriptor, as returned by os.open().
      position
        Position, interpreted relative to 'whence'.
      whence
        The relative position to seek from. Valid values are:
        - SEEK_SET: seek from the start of the file.
        - SEEK_CUR: seek from the current file position.
        - SEEK_END: seek from the end of the file.

    The return value is the number of bytes relative to the beginning of the file.


C:\Users\ctynd>