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 > 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 not get jumbled u

Re: List iterator thread safety

2009-08-27 Thread Carl Banks
On Aug 27, 7:25 am, Hendrik van Rooyen 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 of objects, a

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

Re: List iterator thread safety

2009-08-27 Thread Carl Banks
On Aug 27, 5:03 am, "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 pr

Re: List iterator thread safety

2009-08-27 Thread Xavier Ho
On Tue, Aug 25, 2009 at 3:43 AM, Emanuele D'Arrigo 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 something sim

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 tw

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 a

Re: List iterator thread safety

2009-08-26 Thread Aahz
In article , Emanuele D'Arrigo 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. Am I right to say this -won't- generate except

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 concern