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

Nick Efford nde at
Wed Jun 20 07:07:49 EDT 2001

On Wed, 20 Jun 2001 08:55:12 -0000,
karthik_guru at <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)?

func is a class attribute because it is defined within the class;
foo and bar are instance attributes because they are defined
when an instance of the class is created.

func is effectively inherited by the instance because, when
you do t.func(), Python will look for the name 'func' in
the namespace of t's class if it fails to find the name in
t's namespace.


More information about the Python-list mailing list