title: c# convert string to python object
body: <p>There is all kinds of craziness happening in my shop. The request is an odd one, but understand I have no choice. I need to convert the string representation of an ironpython dictionary into an actual ironpython dictionary... and I need to do it in c#. The dictionary is being retrieved from a database, so there is no chance I can get it in any other form.</p>
  
  <p>I have made some progress here. So far I have the following:</p>
  
  <pre><code>        string python_dict = SqlSession.getPythonDictFromDatabase();
  
          ScriptEngine engine = Python.CreateEngine();
  
          ScriptSource source = engine.CreateScriptSourceFromString(python_dict, SourceCodeKind.Expression);
  
          PythonDictionary dict = source.Execute&lt;PythonDictionary&gt;();
  </code></pre>
  
  <p>The above code successfully converts the string into a python dictionary. Great so far. Unfortunately, the nested classes within the dictionary are still strings. There are all sorts of things in there varying from strings and ints to SetCollections. I need the entire datastructure converted into the c# representation of python objects. I could conceivably iterate through the structure whilst performing conversions just like I did with the dict initially. This seems very messy. It also seems fragile.</p>
  
  <p>The worst part about all this? I actually had this working about a month ago. The source code was lost. Anyone know how I can convert this string into a fully represented python data structure?</p>