filtering a list

Robin Becker robin at jessikat.demon.co.uk
Mon Aug 23 15:47:29 CEST 1999


I'm uncertain as to whether this kind of construct is well formed

R is a list of instances

for i in R:
  if i.id%2: del R[R.index(i)]

or is it better (assuming R holds the only references to the instances)
to do

R=filter((lambda x: x.id%2),R)
-- 
Robin Becker




More information about the Python-list mailing list