Mainpulating values yielded by the find method¶
Also with at you can manipulate values :
code continued from the above example
>>> [ a.at(e.path , lambda v : v * -10 ) for e in a.find( lambda k, v : k.endswith('x')) ]
[-10, 10]
>>> a.tprint()
{
a : {
y : 2,
x : -10,
z : 3,
},
b : {
y : -1,
x : 10,
z : -2,
},
}
Warning
- Since it is pretty not a good idea to change a collection while it is being iterated any in situ search / replace at the same time is strongly discouraged;
- Always work with the path when manipulating