do we have an API reference which will describe what each function
will do, like many other languages?
Apart from reading the python docs/tutorials, you can use help to see the docstring of the methods/functions
In [443]: help(object.__hash__)
Help on wrapper_descriptor:
__hash__(...)
x.__hash__() <==> hash(x)
If you're using the ipython interactive shell, simply use ? instead of help function:
In [446]: object.__hash__?
Type: wrapper_descriptor
String Form:<slot wrapper '__hash__' of 'object' objects>
Namespace: Python builtin
Docstring: x.__hash__() <==> hash(x)
You can even use ?? to access the source of a function, e.g.:
In [454]: os.path.getsize??
Type: function
String Form:<function getsize at 0x01C6DEF0>
File: d:\anaconda\lib\genericpath.py
Definition: os.path.getsize(filename)
Source:
def getsize(filename):
"""Return the size of a file, reported by os.stat()."""
return os.stat(filename).st_size
In [455]:
dir(object)