where is the __dict__ ?

Aahz aahz at pythoncraft.com
Thu Sep 19 10:29:02 EDT 2002

In article <3d89b79b$1 at news.sentex.net>,
Peter Hansen  <peter at engcorp.com> wrote:
>black wrote:
>>   my book said all dictionaries have __dict__ method but couldnt find
>>   it by using dir(), where is it ?
>Your book is probably wrong, since dictionaries don't have a __dict__ 
>method.  In 2.2 their *classes* do, although dir() still doesn't show

__dict__ is an *attribute*, not a method:

class C:
    a = 1

print C.__dict__
print C().__dict__

x = C()
x.foo = 5

print x.__dict__
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/

More information about the Python-list mailing list