Recursively call 'visitor' on all the children of a dictionary
(obj, visitor, parent_key=None)
| 176 | |
| 177 | |
| 178 | def walk(obj, visitor, parent_key=None): |
| 179 | """ |
| 180 | Recursively call 'visitor' on all the children of a dictionary |
| 181 | """ |
| 182 | visitor(obj, parent_key) |
| 183 | if isinstance(obj, dict): |
| 184 | for k, v in obj.items(): |
| 185 | walk(v, visitor, parent_key=k) |
| 186 | elif isinstance(obj, list): |
| 187 | for v in obj: |
| 188 | walk(v, visitor) |
| 189 | |
| 190 | |
| 191 | class PR: |