Add DotDict.__iter__, yields key value pairs.

master
voussoir 2022-01-19 20:57:04 -08:00
parent 83a3bee53d
commit 053a25cc58
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 5 additions and 0 deletions

View File

@ -25,6 +25,11 @@ class DotDict:
def __setattr__(self, key, value): def __setattr__(self, key, value):
self.__dict__[key] = value self.__dict__[key] = value
def __iter__(self):
display = self.__dict__.copy()
display.pop('_DotDict__default')
return iter(display.items())
def __repr__(self): def __repr__(self):
display = self.__dict__.copy() display = self.__dict__.copy()
display.pop('_DotDict__default') display.pop('_DotDict__default')