Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPython__slots__ layoutSingle-choice MCQ

Why does a class using `__slots__` (without listing `__weakref__`) break `weakref.ref()`, and how is it fixed?

import weakref class F: __slots__ = ('a',) f = F() weakref.ref(f)