Make Irc.removeCallback shorter and more readable.

This commit is contained in:
Jeremy Fincher 2003-04-16 17:53:55 +00:00
parent 5a11ebd8bd
commit 15f7dfe430

View File

@ -327,15 +327,8 @@ class Irc(object):
self.callbacks.append(callback)
def removeCallback(self, name):
ret = []
toRemove = []
for (i, cb) in enumerate(self.callbacks):
if cb.name() == name:
toRemove.append(i)
for i in reviter(range(len(self.callbacks))):
if toRemove and toRemove[-1] == i:
toRemove.pop()
ret.append(self.callbacks.pop(i))
ret = filter(name.__eq__, self.callbacks)
self.callbacks[:] = [cb for cb in self.callbacks if name != cb.name()]
return ret
def queueMsg(self, msg):