I have been working to build a complex data structure which would return a dictionary. Currently that class return string object of the form
{ cset : x,
You probably do want to use Pickle:
http://docs.python.org/library/pickle.html#pickle.dumps
It can also return the value as a string, rather than writing to a file.