title: How to split the return of socket,gethostbyaddr and write to file?
body: <p>I have a script that reads addresses from a file and looks up its hostname with socket.gethostbyaddr, however the return of this function is messy and doesn't look right.</p>
  
  <p>The line where it writes to the destination file reads:</p>
  
  <pre><code>destfile.write(str(socket.gethostbyaddr(ip)))
  </code></pre>
  
  <p>The results come out like this when it reads 8.8.8.8:</p>
  
  <pre><code>('google-public-dns-a.google.com', [], ['8.8.8.8])
  </code></pre>
  
  <p>However, I only need that first output, google-public-dns-a.google.com. I hope to have it write to the file and look like this:</p>
  
  <pre><code>8.8.8.8 resolves to google-public-dns-a.google.com
  </code></pre>
  
  <p>Anyone know how to split this? Can provide more code if needed.</p>