Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPythondescriptorsSingle-choice MCQ

A class with __slots__ has a subclass that omits __slots__. The subclass instance can take arbitrary attributes again. What is the runtime reason?

class Base: __slots__ = ('a',) class Sub(Base): pass s = Sub() s.anything = 1 print(hasattr(s, '__dict__'))