Splitting lists

Terry Reedy tjreedy at udel.edu
Thu Feb 27 17:31:54 EST 2003


"Létezõ" <letezo at fw.hu> wrote in message
news:mailman.1046363056.19603.python-list at python.org...
> # Duncan: (my current favourite)
> fl=[]
> tl = [ x for x in test if fn(x) or fl.append(x) ]

For those not liking list comps, the filter() equivelent is
fl=[]
fa=fl.append
tl = filter(lambda x: fn(x) or fa(x), test)

Terry J. Reedy






More information about the Python-list mailing list