scope of function parameters (take two)

Ian Kelly ian.g.kelly at gmail.com
Tue May 31 13:10:58 EDT 2011


On Tue, May 31, 2011 at 10:34 AM, Chris Kaynor <ckaynor at zindagigames.com> wrote:
> Is there any reason not to simplify this to:
> def copy_args(f):
>    @functools.wraps(f)
>    def wrapper(*args, **kw):
>        nargs = copy.deepcopy(args)
>        nkw = copy.deepcopy(kw)
>        return f(*nargs, **nkw)
>    return wrapper

No reason, good call.

> It means you will copy the keys as well, however they will (almost)
> certainly be strings which is effectively a no-op.

I think the keys will certainly be strings.  Is there any scenario
where they might not be?



More information about the Python-list mailing list