title: Problem with object oriented comparisons when threading in python
body: <p>im not too bad at python, and ive tried to make a threaded socket client, but ive hit a problem in my code that i cant solve. Here is the code:</p>
  
  <pre><code>import socket
  import threading
  class ThreadedServer(object):
      def __init__(self, host, port, num):
          self.num = num
          self.host = host
          self.port = port
          self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
          self.sock.bind((self.host, self.port))
  
      def listen(self):
          self.sock.listen(1)
          while True:
              client, address = self.sock.accept()
              client.settimeout(600)
              threading.Thread(target = self.listenToClient,args = (client,address)).start()
  
      def listenToClient(self, client, address):
          size = 1024
          # fix this, please
          if self.num == 1:
              print("Client 1 connected")
  
          if self.num == 2:
              print("Client 2 connected")
  
          if self.num == 3:
              print("Client 3 connected")
          while True:
                  data = client.recv(size)
                  data = data.decode("utf-8")
                  print("Client", self.num, ": ", data)                
  
  
                  #   Reply 
                  if data == "lad":
                      response = "nice"
                  else:
                      response = data
  
  
  
                  client.send(response.encode('utf-8'))
  
  
  
  if __name__ == "__main__":
      while True:
          host = input("Host? ")
          port_num = input("Port? ")
          try:
              port_num = int(port_num)
              print("Please connect client")            
              break
          except ValueError:
              pass
  
      ThreadedServer(host,port_num, 1).listen()
      ThreadedServer(host,port_num, 2).listen()
      ThreadedServer(host,port_num, 3).listen()
  
      ThreadedServer.listenToClient()
  </code></pre>
  
  <p>You see, when i run this, i also connect it to a rather simple client, which sends me data.
  In this code, the data i receive is amply called 'data'.
  The problem i have in this code is that in the section where i repeat 'if self.num:', i plan for it to give me the following code when i connect 3 client:</p>
  
  <pre><code>Client 1 connected
  Client 2 connected
  Client 3 connected
  </code></pre>
  
  <p>but instead it simply repeats 'Client 1 connected' 3 times.</p>
  
  <p>It would be great if anyone could try to solve this problem for me, thanks in advance</p>
  
  <p>Ps: If anyone would like the client too, just ask for it, and i will edit this post to add it in.</p>