I am running a small client-server test in python and the client sends a word to the server. This word is the name of a function in python it needs to call. So when the word "blink" is sent, it should call the function "blink". (Please not that their could be several keywords and function so it needs to be some form of variable function call).
while True:
s.listen(1)
conn, addr = s.accept()
print 'Connection address:', addr
while 1:
data = conn.recv(BUFFER_SIZE)
if not data: break
if data == "blink":
print "MATCH!"
call(data())
print "received:",data
call(data())
print "break"
The word MATCH is printed to clearly the word is received. How to now use the variable data to call the function blink?
I now get
TypeError: 'str' object is not callable
I can understand the error.. clearly I need to do something with that string.. any ideas?