I have two different class
class ircChannel:
NAME = ""
def __init__(self):
self.NAME = NAME
class ircServer:
HOST = ""
PORT = 0
CHAN = []
def __init__(self, HOST, PORT):
self.HOST = HOST
self.PORT = PORT
def addChan(self, CHANEL):
self.CHAN.append(CHANEL)
I am parsing an XML file and create a list of ircServer containing a list of ircChannel
for server in servers
ircBot.addServer(ircServer(HOST, PORT))
for channel in channels
ircBot.SERVERS[-1].addChan(ircChannel(channel.name))
And when I print the result, I kept getting duplicate
ircBot
Server 1 -
Channel1
Channel2
Channel3
Server 2 -
Channel1
Channel2
Channel3
But all I need is
ircBot
Server 1 -
Channel1
Channel2
Server 2 -
Channel3
Why doest the two list keep having the same channels when I obviously create two different instances of irsServer and add different channels ?
I tried emptying the list in the init of the ircServer class but it's not working.