[back on-list] Laszlo Nagy wrote: > >> Ir probably would be helpful to add the method, but it might be tricky >> to trap changes to the mapping as iteration proceeded: what kind of >> isolation would you implement? > Probably I would do the same that Python does with dicts: > > >>> d = {1:'a',2:'b',2:'c'} > >>> for k in d: > ... if d.has_key(k+1): > ... del d[k+1] > ... print k > ... > 1 > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > RuntimeError: dictionary changed size during iteration > > >>> d = {1:'a',2:'b',2:'c'} > >>> for k in d: > ... del d[k+1] > ... d[k+100] = 'XXX' > Traceback (most recent call last): > File "<stdin>", line 2, in <module> > KeyError: 102 > > E.g. I would not allow to change the keys of the gdbm object during > iteration. I'm not sure how to detect "end of iteration" though. > > (Maybe I misunderstood your question.) > All I meant was that it's essential to trap this condition.
regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline -- http://mail.python.org/mailman/listinfo/python-list