def tuple2dict(mytuple, constructor=dict):
result = constructor()<EOL>for elt in mytuple:<EOL><INDENT>key, value = elt<EOL>if type(value) == type(()):<EOL><INDENT>key_value = tuple2dict(value, constructor=constructor)<EOL><DEDENT>elif type(value) == type([]):<EOL><INDENT>key_value = []<EOL>for elt in value:<EOL><INDENT>key_value.append(tuple2dict(elt, constructor=constructor))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>key_value = value<EOL><DEDENT>result[key] = key_value<EOL><DEDENT>return result<EOL>
Turn a tuple as returned by dict2tuple back
into a dictionary structure. The optional
parameter "constructor" governs, what class
is used to create the dictionary: by default,
the standard dict class is used, but in DINGO
we mostly use the DingoObjDict class.