I am learning a piece of code as follows:
class TestApp(TestWrapper, TestClient):
def __init__(self, ipaddress, portid, clientid):
TestWrapper.__init__(self)
TestClient.__init__(self, wrapper=self)
self.connect(ipaddress, portid, clientid)
thread = Thread(target = self.run)
thread.start()
setattr(self, "_thread", thread)
self.init_error()
I am interested in its threading component, I do not understand what setattr does here, can someone please explain?
Many thanks
self._thread = thread. Have you read thesetattrdocumentation?TestAppclass or theTestWrapperclass or theTestClientclass. So my best guess is: You're setting the attribute because you want to access it later.