I'm banging my head against my desk trying tu understand what I'm doing wrong.
class Endpoint:
PortID = 0
MAC = ''
IP = ''
FQDN = ''
__init__()...
class Interface:
Index = 0
Endpoints = []
__init__()
...
im main section i have:
for i in interfaces: #list of Interface objects
for e in endpoints: #list of Endpoint objects
is (some condidions):
i.Endpoints.append(e)
i.print() # prints all endpoints connected to the interface
Then in the output I have something like this:
ge0/0:
11:11:11:11:11:11
ge0/1:
11:11:11:11:11:11
22:22:22:22:22:22
ge0/2
11:11:11:11:11:11
22:22:22:22:22:22
33:33:33:33:33:33
where what I intend to get is:
ge0/0:
11:11:11:11:11:11
ge0/1:
22:22:22:22:22:22
ge0/2
33:33:33:33:33:33
You get the point. It's like the "i" variable isn't created and destroyed in every loop iteration, but is rather just updated. In other words it's not a representation of a Interface object, but rather some kind of buffer commot to a whole loop. What am I doing wrong? How can I achieve desired goal?
Thank you in advance for your help.