Roy Smith <[email protected]> writes:
>> from heapq import nlargest
>> top = nlargest(K, input())
> In addition to finding the K largest values, I *also* need to do some
> other processing on all the values .... The problem with nlargest()
> is that it doesn't give me a hook to do that.
def processed_input():
for x in input():
process(x)
yield x
top = nlargest(K, processed_input())
You could also write that more consisely with genexps but it's a bit
clumsy.
--
http://mail.python.org/mailman/listinfo/python-list