where does __class__ come from?

patrick.m.lahey at aero.org patrick.m.lahey at aero.org
Tue Aug 23 14:53:33 EDT 2005


Newbie here...

Ok, the following code:

class Base:
    _count = 0
    def __init__(self):
	self.__class__._count += 1
        print dir(self)

x = Base()

the output is:

['__doc__', '__init__', '__module__', '_count']

Notice that __class__ is no where to be seen!

Where does __class__ come from, what does it mean and what else is
being hidden?

I am used to using dir(...) to figure out what I can play with.
Clearly that does not always work... :-(

Thanks!




More information about the Python-list mailing list