I have a tree-like data structure, the basic elements are hash tables, and they are grouped into lists, like [[{'a':1},[{'b':2}]]]. And I want to flat the lists and visit hash table one by one, like {'a':1}, {'b':2}. But my program didn't work as I wish. When it entered the 2nd flat_yield, it threw a GeneratorExit. Is there anything wrong? Thank you very much!
#- - - - - - - - - - def flat_yield(tbl_list): for t in tbl_list: if type(t) == type({}): yield t elif type(t) == type([]): flat_yield(t) a = [[{'a':1},[{'b':2}]]] for i in flat_yield(a): print i -- http://mail.python.org/mailman/listinfo/python-list