title: Python: getting "'socket' object is not subscriptable"
body: <pre><code>def sendToAllClients(messageSender, message):
      # Formatting the message
      messageHeader = f"{len(message) :&lt; {HEADER_LENGTH}}".encode('utf-8')
      messageList = {'header': messageHeader, 'data': message.encode('utf-8')}
      # Send the message to all clients
      for client in clients:
          client.send(messageSender['header'] + messageSender['data'] + messageList['header'] + messageList['data'])
  
  
  def sendMessageTo(messageSender, message, messageTargetUsername):
      # Formatting the message
      messageHeader = f"{len(message) :&lt; {HEADER_LENGTH}}".encode('utf-8')
      messageList = {'header': messageHeader, 'data': message.encode('utf-8')}
      # Go through all clients
      for client in clients:
          # If the client has the same username as the target, send the message only to them
          if clients[client].get('data').decode('utf-8') == messageTargetUsername:
              client.send(messageSender['header'] + messageSender['data'] + messageList['header'] + messageList['data'])
  </code></pre>
  
  <p>Im getting the error "TypeError: 'socket' object is not subscriptable" whenever I'm trying to the sendMessageTo method but not when I use the SendToAllClients method, any ideas why this is happening?</p>
  
  <p>The line that seems to be giving the error is:</p>
  
  <p><code>client.send(messageSender['header'] + messageSender['data'] + messageList['header'] + messageList['data'])</code></p>
  
  <p>But pretty much the same line on sendToAllClients works??</p>