Reputation: 5830
As we can see here: http://docs.python.org/2/library/functions.html#object
Return a new featureless object. object is a base for all new style classes. It has the methods that are common to all instances of new style classes.
What methods specifically according to this? Where is the reference?
Upvotes: 2
Views: 82
Reputation: 34007
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]:
Upvotes: 1
Reputation: 42597
Use the dir()
function to inspect a class or object:
>>> dir(object)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__',
'__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__sizeof__', '__str__', '__subclasshook__']
See also the Python Language Reference, which can be searched to find details on each of these special methods.
Upvotes: 2