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

Graham Ashton graham at
Wed Jun 20 05:38:59 EDT 2001

In article <mailman.993027464.6001.python-list at>, "Unknown"
<karthik_guru at> wrote:

> Both dir(t) and t.__dict__ print only foo and bar. They don't print the
> func which is also a instance attribute (method reference)?
> But they are printed when i do test.__dict__ and dir(test)
> <classname>
> why is it not getting printed in the earlier case?(wiht instance)

I'm not sure about that one (I'm new to this too).

> 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?

Have a look at getattr() for that.

  method = getattr(test, 'func')  # untested

More information about the Python-list mailing list