beginner ques: dir( ) does'nt list my instance methods?

karthik_guru at karthik_guru at
Wed Jun 20 10:55:12 CEST 2001

class test:
    def __init__(self):
        print 'hello test' = 100 = 900
    def func(self):
        print 'hello'

if __name__ == '__main__':
    t = test()    
    print dir(t)
    print t.__dict__

Both dir(t) and t.__dict__ print only foo and bar.
They don't print the func which is also a instance attribute (method 

But they are printed when i do test.__dict__ and dir(test) 
why is it not getting printed in the earlier case?(wiht instance)

I might be required to do a look up from dir(instance) and if an 
attribute happens to be of the type method i can invoke it?


More information about the Python-list mailing list