Re: [Python-ideas] proto-PEP: Fixing Non-constant Default Arguments

there really is no need to have something like that built into the language. most default arguments are immutable anyhow, and i'd guess most of the mutable defaults can be addressed with the suggested @copydefaults decorator. as for uncopyable or stateful defaults (dev = sys.stdout), which require reevaluation, you can just use this modified version of my first suggested decorator:
the defaults are now provided as *functions*, which are evaluated at the time of calling the function.
this means you can do things like --
decorators are powerful enough for this not-so-common case. it would be nice to have a collection of useful decorators as part of stdlib (such as these ones, but including memoize and many others)... but that's a different issue. maybe we should really start a list of useful decorators to be included as an stdlib module. -tomer
participants (1)
-
tomer filiba