__slots__
declaration allows to restrict dynamic attributes declaration. But this is just one from a bunch of side effects of __slots__
. How to restrict dynamic attributes declaration without __slots__
?
Desired syntax:
class A(SomeSmrtClass):
__allowed_attrs = set(['a', 'b'])
Desired behavior:
>>> a = A()
>>> a.a = 1 # Allowed
>>> a.c = 2 # Allowed in SomeSmartClass by deault
>>> a.d = 3
AttributeError: ...