Re: pivot() equivalent

2010-03-11 Thread MRAB
gundlach wrote: I *know* this already exists, but I can't remember where: def pivot(func, seq): # I know, a good implementation shouldn't call func() twice per item return ( (x for x in seq if func(x)), (x for x in seq if not func(x)) ) I feel like I read a thread in which this was argued t

Re: pivot() equivalent

2010-03-11 Thread John Posner
On 3/11/2010 6:16 PM, gundlach wrote: I *know* this already exists, but I can't remember where: def pivot(func, seq): # I know, a good implementation shouldn't call func() twice per item return ( (x for x in seq if func(x)), (x for x in seq if not func(x)) ) I feel like I read a thread in

pivot() equivalent

2010-03-11 Thread gundlach
I *know* this already exists, but I can't remember where: def pivot(func, seq): # I know, a good implementation shouldn't call func() twice per item return ( (x for x in seq if func(x)), (x for x in seq if not func(x)) ) I feel like I read a thread in which this was argued to death, and I can