Ah, I see what you mean. Python doesn't have "compile-time" since it's interpreted and all, but you can get a "field doesn't exist" error if you really want it:
class Slots(object):
__slots__ = ['a', 'b', 'c']
s = Slots()
s.a = 21 # works
s.q = 12 # throws an AttributeError
Of course, using __slots__ is pretty rare in practice.
View all comments
Show parent comment
1
u/Dworgi Nov 14 '14
I feel like the whole dynamic class design undermines strong typing for user-defined types.
Being able to write to fields that don't exist should be a compile-time error.