For some reason, the following block of code is only iterating through the for loop once, despite there being 2 entries in the list.
def remove_client(self, client):
try:
temp = client.followedby
for i in temp:
print("Begin")
print(i)
print(client.followedby)
i.unfollow_user()
print(client.followedby)
print("Passed")
print("Out of loop.")
except AttributeError:
print("AttributeError")
pass
self.cur_id[client.id] = False
self.clients.remove(client)
The called function unfollow_user
:
def unfollow_user(self):
self.send_host_message("Stopped following at {}.".format(time.asctime(time.localtime(time.time()))))
self.following.followedby.remove(self)
self.following = ""
print("end of unfollow user")
This should work as to my knowledge. It doesn't throw any error, with the console output being:
[<server.client_manager.ClientManager.Client object at 0x000001F87C2CCE80>, <server.client_manager.ClientManager.Client object at 0x000001F87C2CCD30>] Begin <server.client_manager.ClientManager.Client object at 0x000001F87C2CCE80> [<server.client_manager.ClientManager.Client object at 0x000001F87C2CCE80>, <server.client_manager.ClientManager.Client object at 0x000001F87C2CCD30>] end of unfollow user [<server.client_manager.ClientManager.Client object at 0x000001F87C2CCD30>] Passed Out of loop.
What am I doing wrong, here?