Reading Manual Pages

It is almost sure that you will want to open manual pages for library functions. You can do it with the help of the help command.

In [1]: import numpy

In [2]: help(numpy.ar     
  numpy.arange       numpy.arcsinh      numpy.argmax       numpy.argwhere      
  numpy.arccos       numpy.arctan       numpy.argmin       numpy.around        
  numpy.arccosh      numpy.arctan2      numpy.argpartition numpy.array        >
  numpy.arcsin       numpy.arctanh      numpy.argsort      numpy.array2string

You just type part of the function then press Tab key to get a list of function.

You select the function you wish using the arrow keys then press Enter. Then you close the function call with a ) and press Enter.

Help on ufunc object:

arcsin = class ufunc(builtins.object)
 |  Functions that operate element by element on whole arrays.
 |  
 |  To see the documentation for a specific ufunc, use `info`.  For
 |  example, ``np.info(np.sin)``.  Because ufuncs are written in C
 |  (for speed) and linked into Python with NumPy's ufunc facility,
 |  Python's help() function finds this page whenever help() is called
 |  on a ufunc.
 |  
 |  A detailed explanation of ufuncs can be found in the docs for :ref:`ufuncs`.
 |  
 |  Calling ufuncs:
 |  ===============
 |  
 |  op(*x[, out], where=True, **kwargs)
 |  Apply `op` to the arguments `*x` elementwise, broadcasting the arguments.
 |  
 |  The broadcasting rules are:
 |  
 |  * Dimensions of length 1 may be prepended to either array.
 |  * Arrays may be repeated along dimensions of length 1.
:

You can exist the help screen using Shift+Q.

Another way of achieving the same result is to append a question mark at the end of the function then press Enter (will give you information from docstrings).

In [3]: numpy.arcsin?

The result is something like shown below:

Call signature:  numpy.arcsin(*args, **kwargs)
Type:            ufunc
String form:     
File:            ~/env/data_analysis/lib/python3.5/site-packages/numpy/__init__.py
Docstring:      
arcsin(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])

Inverse sine, element-wise.

Parameters
----------
x : array_like
    `y`-coordinate on the unit circle.
out : ndarray, None, or tuple of ndarray and None, optional
    A location into which the result is stored. If provided, it must have
    a shape that the inputs broadcast to. If not provided or `None`,
    a freshly-allocated array is returned. A tuple (possible only as a
    keyword argument) must have length equal to the number of outputs.
where : array_like, optional
    Values of True indicate to calculate the ufunc at that position, values
    of False indicate to leave the value in the output alone.
:

Note:
In order to use Tab completion you have to have readline installed. You can install it using pip by running the following command in the terminal.

pip install readline

Leave a Reply