Lees de code zorgvuldig
class Compact:
__slots__ = ("x", "y")
class Hybrid(Compact):
__slots__ = ("__dict__",)
c = Compact()
c.x = 1
c.y = 2
try:
c.z = 99
print("compact:z_ok")
except AttributeError:
print("compact:no_z")
h = Hybrid()
h.x = 1
h.y = 2
h.z = 99
print(f"hybrid:{h.x},{h.y},{h.z}")
print(hasattr(c, "__dict__"))
print(hasattr(h, "__dict__"))
Wat zal het programma uitprinten? Schrijf hier: