Hi ALL, I am having a issue with a particular storage of data problem and wanted to know if I am going about it the wrong way.
I have a list of reference numbers associated with a product and I have a socket that listens on a port. Now what happens is the client app connects to the server - sends the product and the associated ref numbers (there are a few per product). I need to be able to store these in a data structure so that when the same product is called again - it can display the ref numbers for that product. I am new to OO programming - so please have mercy ;) eg: class ProductData: def __init__(self,prod): self.prod = prod self.ref = [] def add_ref(self,refno): self.ref.append(refno) def __str__(self): return "%s : %s" % (self.prod,",".join(self.ref)) products = ['table', 'chair', 'couch'] ref_numbers = ['1234','4567', '7890'] detail = {} id = 0 for p in products: detail[id] = ProductData(p) for r in ref_numbers: detail[id].add_ref(r) id = id + 1 for a in detail: print detail[a] so I will get: table : 1234,4567,7890 chair : 1234,4567,7890 couch : 1234,4567,7890 BUT I will need to be able to have this in a while loop - as there is a socket listener there. I keep getting this error: for a in Detail: RuntimeError: dictionary changed size during iteration any ideas ? Thanks Tonino what I want to be able to get is a dict of the products and associated -- http://mail.python.org/mailman/listinfo/python-list