I have data coming in from a machine (via pexpect) and I parse it using regexes into a dictionary like this
for line in stream:
if '/' in line:
# some matching etc which results in getting the
# machine name, an interface and the data for that interface
key=str(hostname)+":"+r.groups()[0][0:2]+r.groups()[2]
dict[key]=str(line[3])
And that all works ok, I get lots of lines like this when I read it back
machine1:fe0 <data>
<data>
is one string or integer
I now realise that multiple data can exist for the interface, and it seems that in this case, I am overwriting the value for the key every time I encounter it. What I would like is to make the key unique in a way which highlights the fact that multiple info exists for that interface. E.g. if fe0 has 3 instances or fe1 has 4
machine1:fe0:3 <data> <data> <data>
machine1:fe1:4 <data> <data> <data> <data>
To that end I don't mind if a single instance has a 1 after it to tell me that.
hope this is clear and someone can point me in the right direction - many thanks