You\'d have already found out by my usage of terminology that I\'m a python n00b.
straight forward question:
How can i see a list of methods for a particular obj
>>> help(my_object)
If you want only methods, then
def methods(obj):
return [attr for attr in dir(obj) if callable(getattr(obj, attr))]
But do try out IPython, it has tab completion for object attributes, so typing obj.<tab>
shows you a list of available attributes on that object.
Python supports tab completion as well. I prefer my python prompt clean (so no thanks to IPython), but with tab completion.
Setup in .bashrc or similar:
PYTHONSTARTUP=$HOME/.pythonrc
Put this in .pythonrc:
try:
import readline
except ImportError:
print ("Module readline not available.")
else:
print ("Enabling tab completion")
import rlcompleter
readline.parse_and_bind("tab: complete")
It will print "Enabling tab completion" each time the python prompt starts up, because it's better to be explicit. This won't interfere with execution of python scripts and programs.
Example:
>>> lst = []
>>> lst.
lst.__add__( lst.__iadd__( lst.__setattr__(
lst.__class__( lst.__imul__( lst.__setitem__(
lst.__contains__( lst.__init__( lst.__setslice__(
lst.__delattr__( lst.__iter__( lst.__sizeof__(
lst.__delitem__( lst.__le__( lst.__str__(
lst.__delslice__( lst.__len__( lst.__subclasshook__(
lst.__doc__ lst.__lt__( lst.append(
lst.__eq__( lst.__mul__( lst.count(
lst.__format__( lst.__ne__( lst.extend(
lst.__ge__( lst.__new__( lst.index(
lst.__getattribute__( lst.__reduce__( lst.insert(
lst.__getitem__( lst.__reduce_ex__( lst.pop(
lst.__getslice__( lst.__repr__( lst.remove(
lst.__gt__( lst.__reversed__( lst.reverse(
lst.__hash__ lst.__rmul__( lst.sort(
Do this:
dir(obj)
dir( object )
will give you the list.
for instance:
a = 2
dir( a )
will list off all the methods you can call for an integer.
Its simple do this for any object you have created
dir(object)
it will return a list of all the attributes of the object.