def autoDeepMap(f): "Decorates a function of one argument to automatically deep-map over multiple or iterable arguments" def mapped(*args): if len(args) != 1: return [mapped(x) for x in args] elif getattr(args[0], '__iter__', False): return [mapped(x) for x in args[0]] else: return f(args[0]) return mapped