title: PyQt : make a Dict from Text Edit, or transform a PyQt4.QtCore.QStringList in common Dict
body: <p>I get from QtextEdit some "code", I mean something like :</p>
  
  <pre><code>1, A, B, D, 1
  1, B, B, D, 2
  2, A, C, G, 1
  </code></pre>
  
  <p>and I would like to get a dictionary like :</p>
  
  <p><code>table={'1':{'A':['B', 'D', '1'], 'B':[B, D, 2]}, '2':{A:['C', 'G', '1']}</code></p>
  
  <p>And then access it: <code>Var=table[1][A][B]</code></p>
  
  <p>but my table is : <code>PyQt4.QtCore.QStringList</code> object at <code>0xb50094c4</code></p>
  
  <p>and I get error : </p>
  
  <pre><code>  File "main.py", line 45, in initMachine
      self.TM.execute_TM(self.a, c, etat1) 
    File "/home/unifesp/Qt_Applications/Ruban.py", line66, in execute_TM
  nvSymb=self.table[etatAct][symb][0]
  TypeError: string indices must be integers
  </code></pre>
  
  <p>The problem come from <code>QStringList</code> format ?  </p>
  
  <pre><code>def initMachine(self):
      etat1=self.etat_1.text()
      b = self.Table.toPlainText()
      c=self.TM.obtenir_table(b)
      print c
  
  def obtenir_table(self, code):
      code=str(code)
      self.a=code.split("\n")
      table={}
      for i in range(len(self.a)):
         b=self.a[i].split(', ')
  
         etat=b[0]
         symbole=b[1]
         if etat=='':
            print "ligne %i" %(i+1) + " : erreur "
         if not table.has_key(etat):
            table[etat] = {}
         if not table[etat].has_key(symbole):
            table[etat][symbole]=b[2:]
         else: 
             print "ligne %i" %(i+1) +" : already declare"
      self.table=self.convert_dict(table)
  
  def convert_dict(self, dictionary):
      if not isinstance(dictionary, dict):
          return dictionary
      return dict((str(k), self.convert_dict(v)) 
          for k, v in dictionary.items())
  def execute_TM(self, table, ruban, etat1):
      self.Ruban.position=1
      self.table=unicode(table)
      etatAct=str(etat1)
      while etatAct != 'stop':
          symb=self.Ruban.lire_cellules()
          print symb
          print table
          nvSymb=self.table[etatAct][symb][0]
          self.Ruban.ecrire(nvSymb)
          if table[etatAct][symb][1]=='D':
              self.Ruban.deplacement_droite()
          if table[etatAct][symb][1]=='G':
              self.Ruban.deplacement_gauche()
          else: 
             print "erreur code deplacement"
          etatAct=table[etatAct][symb][2]
  </code></pre>
  
  <p>I have tried many different things, here the last version of what I have tried.... </p>
  
  <p>Thanks for your Help!</p>