title: Python dictionary with list, how to describe it in a thrift stub code?
body: <p>I am trying to send a python dictionary <code>{"1": ["2", 3, 4]}</code>. Server and client <a href="http://tkang.blogspot.com/2010/07/thrift-server-client-in-python.html" rel="nofollow">as here</a>, only used <code>TSocket.TServerSocket(unix_socket="socket")</code> and
  <code>TSocket.TSocket(unix_socket="socket")</code>
  accordingly.The function returns a dictionary called <code>get_stats()</code>.</p>
  
  <p><strong>File <code>stats.thrift</code></strong></p>
  
  <pre><code>struct Stat{
    1: required string login
    2: required i32 connections}
  service Stats{
    map&lt;string,list&lt;Stat&gt;&gt; get_stats()}
  </code></pre>
  
  <p><strong>generation code</strong> <code>thrift --gen py stats.thrift</code></p>
  
  <p>But when call the function, I get an error on the server side:</p>
  
  <pre><code>ERROR:root:'str' object has no attribute 'write'
  Traceback (most recent call last):
    *more text*
    File "gen-py/stats/Stats.py", line 189, in write
      iter15.write(oprot)
  AttributeError: 'str' object has no attribute 'write'
  </code></pre>
  
  <p><strong>Function <code>write()</code></strong></p>
  
  <pre><code>def write(self, oprot):
      if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
        oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
        return
      oprot.writeStructBegin('get_stats_result')
      if self.success is not None:
        oprot.writeFieldBegin('success', TType.MAP, 0)
        oprot.writeMapBegin(TType.STRING, TType.LIST, len(self.success))
        for kiter13,viter14 in self.success.items():
          oprot.writeString(kiter13)
          oprot.writeListBegin(TType.STRUCT, len(viter14))
          for iter15 in viter14:
            iter15.write(oprot)
          oprot.writeListEnd()
        oprot.writeMapEnd()
        oprot.writeFieldEnd()
      oprot.writeFieldStop()
      oprot.writeStructEnd()
  </code></pre>
  
  <p>why the thrift generated code:</p>
  
  <pre><code>for iter15 in viter14:
    iter15.write(oprot)
  </code></pre>
  
  <p><strong>Questions:</strong><br>
  Why called method <code>write()</code> for type <code>str</code>?<br>
  Where I'm wrong?<br>
  In <code>stats.thrift</code>?<br>
  In Server or Client code?<br>
  In <code>thrift --gen</code> command?  </p>