[Python-Dev] functools additions (original) (raw)
BJörn Lindqvist bjourne at gmail.com
Mon Apr 16 00:36:42 CEST 2007
- Previous message: [Python-Dev] functools additions
- Next message: [Python-Dev] Py3: function signatures, type checking, and related crap
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
def cat(x): return x
def multimap(func, s, n=2): assert n > 0, "n must be positive" return (map(func, seq) if n == 1 else map(lambda x: multimap(func, x, n-1), seq)) def multifilter(func, s, n=2): return multimap(lambda x: filter(func, x), s, n-1) def multireduce(func, s, n=2): return multimap(lambda x: reduce(func, x), s, n-1) class nullfunc(object): def call(self, *a, **k): return self _def getattr(self, name): return getattr(None, name)
Could you describe what these functions do? Preferably with examples that demonstrates that they are useful.
-- mvh Björn
- Previous message: [Python-Dev] functools additions
- Next message: [Python-Dev] Py3: function signatures, type checking, and related crap
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]