Re: Proposal: SimpleNamespace "recursive" parameter

2020-08-13 Thread Marco Sulla
This seems to work: from types import SimpleNamespace from collections.abc import Iterable def isIterableNotStr(arg): return isinstance(arg, Iterable) and not isinstance(arg, str) class DeepNamespace(SimpleNamespace): def namespacesFromIterable(self, arg): vals = [] chang

Proposal: SimpleNamespace "recursive" parameter

2020-08-13 Thread David Rashty
It would be nice if you could do this to create a "nested" SimpleNamespace: >>> d = {"_meta": {"fields": ({"name": "field0"}, {"name": "field1"})}} >>> sns = SimpleNamespace(**d) >>> print(sns._meta.fields[0].name) # This is what I wish you could do 'field0' SimpleNamespace does this though: >>>