Linked Questions

Popular Questions

Why is my instance variable not in __dict__?

Asked by At

If I create a class A as follows:

class A:
    def __init__(self): = 'A'

Inspecting the __dict__ member looks like {'name': 'A'}

If however I create a class B:

class B:
    name = 'B'

__dict__ is empty.

What is the difference between the two, and why doesn't name show up in B's __dict__?

Related Questions