I'm trying to get a series of serialized dictionaries where only one specific value changes.
the ficticious python dict named "obj"
_gen = (value for value in range(5,10))
obj = {'mcu': {'led0': {'duty': _gen}}}
should "work" like this:
>>> json.dumps(obj)
'{"mcu":{"led0":{"duty": 5}}}
>>> json.dumps(obj)
'{"mcu":{"led0":{"duty": 6}}}
>>> json.dumps(obj)
'{"mcu":{"led0":{"duty": 7}}}
is there a way I can archive this?
It would also be ok to do something like this:
_placeholder = <some trick to create a placeholder>
obj = {'mcu': {'led0': {'duty': _placeholder}}}
should "work" like this
>>> <placeholder modification trick> = 5
>>> json.dumps(obj)
'{"mcu":{"led0":{"duty": 5}}}
>>> <placeholder modification trick> = 6
>>> json.dumps(obj)
'{"mcu":{"led0":{"duty": 6}}}
>>> <placeholder modification trick> = 7
>>> json.dumps(obj)
'{"mcu":{"led0":{"duty": 7}}}