How can I find the function of a python module?
<p>I am using OpenCV, and I want to see what the "rectangle" function is. 
I can use the dir(module) function, to get at the function definition, and name, but I don't know how to view the actual function. I am Using Linux (Ubuntu 16.04), and I'm wondering if the libraries are in "/usr/local/" or some other place. The OpenCV cv2 python library is just an example, I want to know how to view any function of a library, imported into python. </p>

<p>I suggest you to use the wonderful <a href="https://ipython.org/" rel="nofollow">IPython</a> interactive shell.</p>

<p>You can see the definition of any function (or in general of any object whose source code is available) by appending two question marks <code>??</code> to its name. Below is a short example run on my terminal:</p>

<pre><code>$ ipython
Python 2.7.9 (default, Jan 27 2016, 11:42:08) 
Type "copyright", "credits" or "license" for more information.

IPython 2.3.1 -- An enhanced Interactive Python.
?         -&gt; Introduction and overview of IPython's features.
%quickref -&gt; Quick reference.
help      -&gt; Python's own help system.
object?   -&gt; Details about 'object', use 'object??' for extra details.

In [1]: import urllib

In [2]: urllib.urlopen??
Type:        function
String form: &lt;function urlopen at 0x2b56465ac578&gt;
File:        /sw/python/2.7.9/Linux.x86_64/lib/python2.7/urllib.py
Definition:  urllib.urlopen(url, data=None, proxies=None)
Source:
def urlopen(url, data=None, proxies=None):
    """Create a file-like object for the specified URL to read from."""
    from warnings import warnpy3k
    warnpy3k("urllib.urlopen() has been removed in Python 3.0 in "
             "favor of urllib2.urlopen()", stacklevel=2)

    global _urlopener
    if proxies is not None:
        opener = FancyURLopener(proxies=proxies)
    elif not _urlopener:
        opener = FancyURLopener()
        _urlopener = opener
    else:
        opener = _urlopener
    if data is None:
        return opener.open(url)
    else:
        return opener.open(url, data)
</code></pre>

python function opencv module