James Stroud wrote:
>
> It seems I need constructs like this all of the time
>
> i = 0
> while i < len(somelist):
>   if oughta_pop_it(somelist[i]):
>     somelist.pop(i)
>   else:
>     i += 1
>
> There has to be a better way...
>

! for i in xrange(len(somelist)-1, -1, -1):
!     if oughta_pop_it(somelist[i]):
!         del somelist[i] # why use pop??

We don't need no stinking iterators; we're the
Python_1.5_or_earlier_istas!

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to