title: Python - AttributeError: 'tuple' object has no attribute 'read'
body: <p>I am working on a simple python client and server that can write code to a file as its sent. So far I have been stuck on this error: AttributeError: 'tuple' object has no attribute 'read'</p>
  
  <p>Here is the client's code:</p>
  
  <pre><code># CCSP Client
  # (C) Chris Dorman - 2013 - GPLv2
  
  import socket
  import sys
  
  # Some settings
  host = raw_input('Enter the Host: ')
  port = 7700
  buff = 24
  connectionmax = 10
  
  # Connect to server
  server = socket.socket()
  server.connect((host, port))
  
  print 'Connected!'
  
  while True:
      open_file = raw_input("File (include path): ")
      fcode = open(open_file, "rb")
      while True:
          readcode = fcode.read(buff)
          server.send(readcode)
          if not fcode:
              server.send("OK\n")
              print "Transfer complete"
              break
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code># CCSP Server
  # (C) Chris Dorman - 2013 - GPLv2
  
  import socket
  import sys
  import string
  import random
  
  def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
      return ''.join(random.choice(chars) for x in range(size))
  
  host = "0.0.0.0"
  port = 7700
  buff = 1024
  filepath = "/home/chris/"
  extension = ".txt"
  
  server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  server.bind((host, port))
  
  print "Server Started"
  
  
  while True:
      server.listen(1)
      conn = server.accept()  
      print 'Client' + str(conn)
      print 'Generating a random file'
      filename = filepath + str(id_generator()) + extension
      fcode = open(filename, "wb")
      while True:
          if conn != 0: 
              code = conn.read(buff)
              fcode.write(buff)
              if conn == "DONE": 
                  print 'Transfer complete'
                  break #EOT
  </code></pre>
  
  <p>Any help with getting this to work would be awesome. I just keep getting that dumb error when it gets down to: <code>code = conn.read(buff)</code> on the servers script</p>