Favorite non-python language trick?

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sat Jun 25 14:36:51 EDT 2005


On Sat, 25 Jun 2005 17:41:58 +0200, Konstantin Veretennicov wrote:

> On 6/25/05, Mandus <mandus at gmail.com> wrote:
>> It is really a consensus on this; that
>> removing map, filter, reduce is a good thing? It will render a whole lot
>> of my software unusable :(
> 
> I think you'll be able to use "from __past__ import map, filter,
> reduce" or something like that :) They don't have to be built-in.

More likely they will be moved to something like itertools than "__past__".

Or just define them yourself:

def map(f, seq):
        return [f(x) for x in seq]

def filter(p, seq):
    return [x for x in seq if p(x)]

def reduce(f, seq, zero):
    r = zero
    for x in seq: r = f(r, x)
    return r

-- 
Steve.





More information about the Python-list mailing list