Python users,<br> I am parsing an AIX trace file and creating a dictionary containing keys (PIDS) and values (a list of TIDS). With PIDS being unique process ids and TIDS, being a list of thread ids. My function populates the keys so that they are unique, but my list contains duplicates.<br>
<br> Can someone point me in the right direction so that my dictionary value does not contain duplicate elements?<br><br><br>here is what I got.<br><br>--------------<portion of code that is relevant>------------------<br>
<br>pidtids = {}<br><br># --- function to add pid and tid to a dictionary<br>def addpidtids(pid,tid):<br> pidtids.setdefault(pid,[]).append(tid)<br><br># --- function to parse a file<br>def grep(pattern, fileObj, include_line_nums=False):<br>
r=[]<br> compgrep = re.compile(pattern)<br><br> for line_num, line in enumerate(fileObj):<br> if compgrep.search(line):<br> info = line.split()<br> p = info[7].lstrip("pid=")<br>
t = info[8].lstrip("tid=")<br> addpidtids(p,t)<br><br><br># process <a href="http://trace.int">trace.int</a><br>tf = open(tracefile, 'r')<br>grep("cmd=java pid",tf)<br>tf.close()<br>
<br>--------------</portion of code that is relevant>------------------<br><br>Any help would be greatly appreciated.<br><br><br>Thanks,<br>Chad<br clear="all"><br>-- <br>A grasshopper walks into a bar and the bartender says "Hey, we have a drink named after you." And the grasshopper says "Really, You have a drink named Murray?"<br>