⬅︎ Back to When to __deepcopy__ classes in Python
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]
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.
Comment
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
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.