The code I have is:
class New(Server):
noOfCl = 0
def onConnect(self, socket):
print "Client connected"
print (noOfCl+=1)
I am receiving the following error: UnboundLocalError: local variable 'noOfCl' referenced before assignment. From what I understand, I’m declaring noOfCl before I am referencing it. Anyone have any ideas as to what I’m doing wrong?
Thanks
As
noOfClis a Class Variable you need to prefix the Class Name before it.Also your in-place update when calling the
printfunction/statement is not supported in Python.