The __iter__ method is currently designed to help dict() work easily, but it makes for-loops deal with dicts, making things clumsy when working with loops.
Find a way to continue using __iter__ as dicts for calls to dict(), while avoiding this type of interaction in loops.
from some_module_resource import module_json_resource
dict(module_json_resource)
# {"first": {"namedtuple": True}, "second": {"namedtuple": True}}
for resource_key, dict_value in module_json_resource:
namedtuple_value = getattr(module_json_resource, resource_key)
print(hasattr(namedtuple_value.second))
The
__iter__method is currently designed to helpdict()work easily, but it makes for-loops deal with dicts, making things clumsy when working with loops.Find a way to continue using
__iter__as dicts for calls todict(), while avoiding this type of interaction in loops.