Re: List iterator thread safety

2009-08-28 Thread Hendrik van Rooyen
On Thursday 27 August 2009 16:50:16 Carl Banks wrote: On Aug 27, 7:25 am, Hendrik van Rooyen hend...@microcorp.co.za wrote: Its not too bad - if you crook a bit - the trick is that you iterate over the list backwards when you are removing stuff based on index, so that the remainder does

Re: List iterator thread safety

2009-08-27 Thread Emanuele D'Arrigo
On Aug 27, 2:01 am, a...@pythoncraft.com (Aahz) wrote: Well, I'm not sure about exceptions, but you almost certainly won't get the results you want. What I'd like in this context is to iterate through the items in the list without processing the same item twice and without skipping item that

Re: List iterator thread safety

2009-08-27 Thread Peter Otten
Emanuele D'Arrigo wrote: On Aug 27, 2:01 am, a...@pythoncraft.com (Aahz) wrote: Well, I'm not sure about exceptions, but you almost certainly won't get the results you want. What I'd like in this context is to iterate through the items in the list without processing the same item twice and

Re: List iterator thread safety

2009-08-27 Thread Xavier Ho
On Tue, Aug 25, 2009 at 3:43 AM, Emanuele D'Arrigo man...@gmail.com wrote: Let's say I have a list accessed by two threads, one removing list items via del myList[index] statement the other iterating through the list and printing out the items via for item in myList: statement. I tried

Re: List iterator thread safety

2009-08-27 Thread Carl Banks
On Aug 27, 5:03 am, Emanuele D'Arrigo man...@gmail.com wrote: On Aug 27, 2:01 am, a...@pythoncraft.com (Aahz) wrote: Well, I'm not sure about exceptions, but you almost certainly won't get the results you want. What I'd like in this context is to iterate through the items in the list

Re: List iterator thread safety

2009-08-27 Thread Hendrik van Rooyen
On Thursday 27 August 2009 15:26:04 Carl Banks wrote: Deleting items from a list while iterating over it is a bad idea, exceptions or not. Hmm, this sounds like something someone might do for a game. You have a list of objects, and in a given time step you have to iterate through the list

Re: List iterator thread safety

2009-08-27 Thread Carl Banks
On Aug 27, 7:25 am, Hendrik van Rooyen hend...@microcorp.co.za wrote: On Thursday 27 August 2009 15:26:04 Carl Banks wrote: Deleting items from a list while iterating over it is a bad idea, exceptions or not. Hmm, this sounds like something someone might do for a game.  You have a list

Re: List iterator thread safety

2009-08-26 Thread Aahz
In article b7796993-219d-4f18-aea3-9af95468c...@z31g2000yqd.googlegroups.com, Emanuele D'Arrigo man...@gmail.com wrote: Let's say I have a list accessed by two threads, one removing list items via del myList[index] statement the other iterating through the list and printing out the items via for

List iterator thread safety

2009-08-24 Thread Emanuele D'Arrigo
Let's say I have a list accessed by two threads, one removing list items via del myList[index] statement the other iterating through the list and printing out the items via for item in myList: statement. Am I right to say this -won't- generate exceptions because the list iterator is not concerned