On Tue, 18 Jan 2005 23:09:57 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: > @with_consts(i=1, deftime=time.ctime()) > def foo(x, y=123, *args, **kw): > return x*y, kw.get('which_time')=='now' and time.ctime() or deftime > > Then you don't have to mix parameter declarations with locals definitions. > > [1] I have no idea how implementable such a decorator would be. I'd > just like to see function constants declared separate from arguments > since they mean such different things.
(untested) def with_constant(**constants_kwargs): def decorator(f) def closure(*arg, **kwargs): kwargs.update(constants_kwargs) return f(*arg, **kwargs) return closure return decorator Regards, Stephen Thorne -- http://mail.python.org/mailman/listinfo/python-list