Consider this code:
>>> class Foo(): pass ... >>> foo = Foo() >>> foo.a = 'test' >>> foo.a 'test'
One can just override
__setattr__ to make attributes read only and prevent their creation at runtime, however:
- Why is this the default Python behavior (any good reasons)?
- Is there any practice to prevent this without altering each class?
- Would you worry about this behavior in serious projects? don't you consider it error prone? or you can just ignore it (relying on new IDEs code completion)