As far as I know, __weakref__ is a descriptor defined in class, so that if it invoked from the instances of the class, it will give the weakref object:
from weakref import ref class A: pass obj = A() wr = ref(obj) print(obj.__weakref__ is wr) # True What about the class A itself? the metaclass type doesn't have __weakref__ descriptor:
print("__weakref__" in type.__dict__) # False Why type metaclass doesn't have that descriptor? then where is it stored? how is it possible to access the weakref object (here wr_of_A) from the class?
from weakref import ref class A: pass wr_of_A = ref(A) print(A.__weakref__) # <attribute '__weakref__' of 'A' objects>