title: Read Null terminated string in python
body: <p>I'm trying to read a null terminated string but i'm having issues when unpacking a char and putting it together with a string.</p>
  
  <p>This is the code:</p>
  
  <pre><code>def readString(f):
      str = ''
      while True:
          char = readChar(f)
          str = str.join(char)
          if (hex(ord(char))) == '0x0':
              break           
      return str
  
  def readChar(f):
      char = unpack('c',f.read(1))[0]
      return char
  </code></pre>
  
  <p>Now this is giving me this error:</p>
  
  <pre><code>TypeError: sequence item 0: expected str instance, int found
  </code></pre>
  
  <p>I'm also trying the following:</p>
  
  <pre><code>char = unpack('c',f.read(1)).decode("ascii")
  </code></pre>
  
  <p>But it throws me:
  AttributeError: 'tuple' object has no attribute 'decode'</p>
  
  <p>I don't even know how to read the chars and add it to the string, Is there any proper way to do this?</p>