there really is no need to have something like that built into the language.<br>most default arguments are immutable anyhow, and i'd guess most of the<br>mutable defaults can be addressed with the suggested @copydefaults
<br>decorator.<br><br>as for uncopyable or stateful defaults (dev = sys.stdout), which require reevaluation,<br>you can just use this modified version of my first suggested decorator:<br><br>>>> def reeval(**kwdefs):
<br>...     def deco(func):<br>...         def wrapper(*args, **kwargs):<br>...             for k, v in kwdefs.iteritems():<br>...                 if k not in kwargs:<br>...                     kwargs[k] = v()               # <--- this is the big change
<br>...             return func(*args, **kwargs)<br>...         return wrapper<br>...     return deco<br>...<br><br>the defaults are now provided as *functions*, which are evaluated at the <br>time of calling the function. 
<br><br>>>> @reeval(device = lambda: sys.stdout)<br>

... def say(text, device):<br>

...     device.write("%s: %s\n" % (<a href="http://device.name">device.name</a>, text))<br>

...     device.flush()<br>

<br>this means you can do things like --<br><br>>>> say("hello1")<br><stdout>: hello1<br>>>><br>>>> say("hello2", device = sys.stderr)<br><stderr>: hello2<br>>>>
<br>>>> sys.stdout = sys.stderr<br>>>> say("hello3")<br><stderr>: hello3<br>>>><br>>>> sys.stdout = sys.__stdout__<br>>>> say("hello4")<br><stdout>: hello4
<br><br>decorators are powerful enough for this not-so-common case. <br><br>it would be nice to have a collection of useful decorators as part of stdlib <br>(such as these ones, but including memoize and many others)... <br>
but that's a different issue. <br><br>maybe we should really start a list of useful decorators to be included <br>as an stdlib module.<br><br><br>-tomer<br>