is this pythonic?

MRAB google at
Wed Jan 21 18:56:59 CET 2009

alex23 wrote:
> On Jan 22, 3:27 am, MRAB <goo... at> wrote:
>> FYI, you shouldn't modify a list you're iterating over.
> But I'm not. I'm building a new list and binding it to the same name
> as the original, which works perfectly fine (unless I'm missing
> something):
I was referring to the code:

     for index, record in enumerate(l):
         if record['title'] == 'ti':

where you are enumerating and iterating over 'l', but also modifying 'l' 
with 'l.pop(index)'.

More information about the Python-list mailing list