def lwrap(f, name=None): def f2(*args, **kwargs): return list(f(*args, **kwargs)) assigned = set(functools.WRAPPER_ASSIGNMENTS) - {'__module__'} _update_wrapper(f2, f, assigned, ()) if name: f2 = rename(f2, name) return f2
def __init__(self, callable, *args, **kwargs): #wrapcall=True, **kwargs): self._wrapcall = kwargs.pop('wrapcall', True) #wrapcall if args or kwargs: self.callable = partial(callable, *args, **kwargs) else: self.callable = callable if isinstance(callable, (type, call)): updated = () else: updated = functools.WRAPPER_UPDATES try: _update_wrapper(self, callable, updated=updated) except AttributeError: _update_wrapper(self, callable, ('__doc__',), updated)