ok, I withdraw that __getattr__ method. It superficially gave me the result that I wanted, but for the wrong reason. super(DotDict) doesn't have a __getattr__, so an AttributeError is raised.
__getattr__ is only called when the normal mechanism for finding an attribute have failed. So this is already the degenerate case. We ought to just be raising the KeyError in there without trying to first call some theoretical super implementation of __gettattr__.
As an aside, the whole idea at this point that things beginning with '_' are to be treated as special is suspect. By the time we get to a call of __getattr__ magic methods have already been resolved. So in your mind, delete my special handling of '_' in a key name.
Comment
ok, I withdraw that __getattr__ method. It superficially gave me the result that I wanted, but for the wrong reason. super(DotDict) doesn't have a __getattr__, so an AttributeError is raised.
__getattr__ is only called when the normal mechanism for finding an attribute have failed. So this is already the degenerate case. We ought to just be raising the KeyError in there without trying to first call some theoretical super implementation of __gettattr__.
As an aside, the whole idea at this point that things beginning with '_' are to be treated as special is suspect. By the time we get to a call of __getattr__ magic methods have already been resolved. So in your mind, delete my special handling of '_' in a key name.