From 053a25cc5802f738f56ce5f444d03dd39af56af0 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 19 Jan 2022 20:57:04 -0800 Subject: [PATCH] Add DotDict.__iter__, yields key value pairs. --- voussoirkit/dotdict.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/voussoirkit/dotdict.py b/voussoirkit/dotdict.py index 3449b77..0f2535b 100644 --- a/voussoirkit/dotdict.py +++ b/voussoirkit/dotdict.py @@ -25,6 +25,11 @@ class DotDict: def __setattr__(self, key, value): self.__dict__[key] = value + def __iter__(self): + display = self.__dict__.copy() + display.pop('_DotDict__default') + return iter(display.items()) + def __repr__(self): display = self.__dict__.copy() display.pop('_DotDict__default')