Python Interpreter Mode - What are some ways to explore Python's modules and its usage
Question: While inside the Python Interpreter:

What are some ways to learn about the packages I have?

    
    
    >>> man sys
    File "<stdin>", line 1
        man sys
          ^
    

SyntaxError: invalid syntax

    
    
    >>> sys --help
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: bad operand type for unary -: '_Helper'
    

Corrected:

    
    
    >>> help(sys)
    ...
    

Now, how do I see all the packages available to me on my sys.path? And see
their subsequent usage and documentation. I know that I can easily download a
PDF but all this stuff is already baked in, I'd like to not duplicate files.

Thanks!


Answer: You can look at `help("modules")`, it displays the list of available modules.
To explore a particular module/class/function use `dir` and `__doc__`:

    
    
    >>> import sys
    >>> sys.__doc__
    "This module ..."
    
    >>> dir(sys)
    [..., 'setprofile', ...]
    
    >>> print(sys.setprofile.__doc__)
    setprofile(function)
    
    Set the profiling function.  It will be called on each function call
    and return.  See the profiler chapter in the library manual.
    

