Re: recursively expanding $references in dictionaries

2007-07-22 Thread Alia Khouri
Ok. I've reached a nice little conclusion here. Time to go to bed, but before that I thought I'd share the results (-; I can now read a yaml file which natively produces a dict tree and convert it into an object tree with attribute read/write access, dump that back into a readable yaml string, and

Re: recursively expanding $references in dictionaries

2007-07-22 Thread Alia Khouri
Oops, I left some redundant cruft in the function... here it is slightly cleaner: def expand(dikt): names = {} output = {} def _search(_, sourceDict): for key, value in sourceDict.items(): if isinstance(value, dict): _search({}, value) if

recursively expanding $references in dictionaries

2007-07-22 Thread Alia Khouri
I was kind of wondering what ways are out there to elegantly expand '$name' identifiers in nested dictionary value. The problem arose when I wanted to include that kind of functionality to dicts read from yaml files such that: def func(input): # do something return output where: input =