In python how to know the methods of a class
Ex: import datetime is a module which has a date class in it..
And print datetime.date.today()
will yield todays date.
How to know all the methods of a class
help(datetime) and dir(datetime) are the only way..?
First solution
Following Björn’s answer and the Dive-into-Python chapter using
callable(getattr(classname)):Second solution – after reading Guandalino‘s comment
This technique relies on the fact that the
__new__attribute is always a method (It can be overridden, but every other keyword can).