Thanks! That's a more clear way!
On Nov 3, 9:38 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> Chris Rebert wrote:
> > On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 <[EMAIL PROTECTED]> wrote:
> >> Hi all,
>
> >> Today I wrote some code like this:
>
> > Build a new list as you go, then overwrite the old list
Chris Rebert wrote:
> On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 <[EMAIL PROTECTED]> wrote:
>> Hi all,
>>
>> Today I wrote some code like this:
>>
>
> Build a new list as you go, then overwrite the old list with it.
>
> unfinished = []
>
>>for m in self.messages:
>>if not m.finishe
M.-A. Lemburg wrote:
>> The typical way to do this is to iterate over the list in reverse
>> order and then using the item index as basis for removing the
>> item:
>>
>> for i, item in enumerate(reversed(mylist)):
>> # process item
>> del mylist[i]
>
> Sorry, the above should read:
>
>
On 2008-11-03 12:12, M.-A. Lemburg wrote:
>> 一首诗 wrote:
>>> Hi all,
>>>
>>> Today I wrote some code like this:
>>>
>>> for m in self.messages:
>>> if not m.finished:
>>> continue
>>>
>>> #process the message
>>>
>>> fini = [m for m in self.mes
> 一首诗 wrote:
>> Hi all,
>>
>> Today I wrote some code like this:
>>
>> for m in self.messages:
>> if not m.finished:
>> continue
>>
>> #process the message
>>
>> fini = [m for m in self.messages if m.finished]
>> for m in fini:
>>
一首诗 wrote:
Hi all,
Today I wrote some code like this:
for m in self.messages:
if not m.finished:
continue
#process the message
fini = [m for m in self.messages if m.finished]
for m in fini:
self.messages.remove(m)
As
On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Today I wrote some code like this:
>
Build a new list as you go, then overwrite the old list with it.
unfinished = []
>for m in self.messages:
>if not m.finished:
unfinished.append(
Hi all,
Today I wrote some code like this:
for m in self.messages:
if not m.finished:
continue
#process the message
fini = [m for m in self.messages if m.finished]
for m in fini:
self.messages.remove(m)
As you can, I w