On 3/13/08, Heshan Suriyaarachchi <[EMAIL PROTECTED]> wrote: > Hi > I am talking about a scenario like this > > class A: > def foo(var1,var2): > return 'Hello' > def echo(): > return 'testing' > > > class B: > def bar(car): > val = car > return car > > What I need is to find out the classes and the methods of each class with > their parameters. > i.e. class A > foo(var,var) > echo() > > when using dir() it does not show the methods and the method parameters .
## foo2.py class A: pass class ABC: pass def foo(): return 'Hello' def bar(): return 899 PI = 22/7 ## print_methods.py import types import foo2 # In python everything is available as a dict all = foo2.__dict__ # run through the items and check whether they are classes are functions for i in all.keys(): if type(all[i]) == types.ClassType: print i, 'is a class' elif type(all[i]) == types.FunctionType: print i, 'is a function' # of course this gives only the top level functions and classes. # Traverse the Tree to get the classes and methods like you wanted. # Pradeep -- Home - http://btbytes.com Heart - http://sampada.net Yummy! - http://konkanirecipes.com _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers