Aaron Brady: > >>> def auto( f ): > > ... def _inner( *ar, **kw ): > ... return f( g, *ar, **kw ) > ... g= _inner > ... return g
Looks nice, I'll try to the following variant to see if it's usable: def thisfunc(fun): """Decorator to inject a default name of a function inside a function""" def _inner(*args, **kwds): return fun(g, *args, **kwds) g = _inner g.__name__ = fun.__name__ g.__dict__.update(fun.__dict__) g.__doc__ = fun.__doc__ g.__module__ = fun.__module__ return g @thisfunc def SOMEVERYUGLYNAME(this, n): return 1 if n <= 1 else n * this(n - 1) assert SOMEVERYUGLYNAME(6) == 2*3*4*5*6 Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list