3 ms·
> Also, naming something implies it will be useful in another context, which one-off lambdas rarely are. Not necessarily. I find it helps readability to do thi
by ctrlc-root 10y ago
> Also, naming something implies it will be useful in another context, which one-off lambdas rarely are.
Not necessarily. I find it helps readability to do this:
def prunde_indices(indices, cutoff):
def match_old_index(index):
return index.timestamp < cutoff
old_indices = filter(match_old_index, indices)
# ... do things with old_indices
as opposed to using an anonymous lambda. That doesn't mean I have to reuse it outside of this function.