468,738 Members | 1,593 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

where does __class__ come from?

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!

Aug 23 '05 #1
2 1462
> 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... :-(


Your question has benn answered - let me just add this from the dir()-docs:

Note: Because dir() is supplied primarily as a convenience for use at
an interactive prompt, it tries to supply an interesting set of names
more than it tries to supply a rigorously or consistently defined set
of names, and its detailed behavior may change across releases.

from

http://docs.python.org/lib/built-in-funcs.html

Regards,

Diez
Aug 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Mars | last post: by
6 posts views Thread by gregory lielens | last post: by
11 posts views Thread by Rob Conner | last post: by
reply views Thread by Gerard Brunick | last post: by
18 posts views Thread by Gabriel Rossetti | last post: by
1 post views Thread by The Pythonista | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.