class static variables and __dict__

Zack goldsz at gmail.com
Sat Feb 16 23:40:07 CET 2008


If I have a class static variable it doesn't show up in the __dict__ of 
an instance of that class.

class C:
    n = 4

x = C()
print C.__dict__
{'__module__': '__main__', '__doc__': None, 'n': 4}
print x.__dict__
{}

This behavior makes sense to me as n is not encapsulated in x's 
namespace but what method can you use on x to find all available 
attributes for that class?

-- 
Zack



More information about the Python-list mailing list