Comment

Patryk Zawadzki

How about not breaking all the magic methods in the first place?

class Foo(dict):
····def __getattr__(self, attr):
········if attr.startswith('__'):
············raise AttributeError(attr)
········return self[attr]

Replies

Peter Bengtsson

Thanks! I like that.
This is why I keep blogging and expose my weaknesses because people like you come in and nudge me in the right direction.