<div>I was thinking you could do something strange like:</div><div><br></div><div>kw = {object(): None}</div><div>def test(**kw):</div><div> print kw</div><div>test(**kw)</div><div><br></div><div>however, upon testing it (in Python 2.6), I found that it errors while trying to unpack the kw dict stating that they must all be strings.</div>
<div><br></div><div>Perhaps making a custom class derived off basestring, str, unicode, or bytes might allow some oddness and possibly slightly worse performance.</div><br clear="all">Chris<br>
<br><br><div class="gmail_quote">On Tue, May 31, 2011 at 10:10 AM, Ian Kelly <span dir="ltr"><<a href="mailto:ian.g.kelly@gmail.com">ian.g.kelly@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, May 31, 2011 at 10:34 AM, Chris Kaynor <<a href="mailto:ckaynor@zindagigames.com">ckaynor@zindagigames.com</a>> wrote:<br>
> Is there any reason not to simplify this to:<br>
> def copy_args(f):<br>
> @functools.wraps(f)<br>
> def wrapper(*args, **kw):<br>
> nargs = copy.deepcopy(args)<br>
> nkw = copy.deepcopy(kw)<br>
> return f(*nargs, **nkw)<br>
> return wrapper<br>
<br>
</div>No reason, good call.<br>
<div class="im"><br>
> It means you will copy the keys as well, however they will (almost)<br>
> certainly be strings which is effectively a no-op.<br>
<br>
</div>I think the keys will certainly be strings. Is there any scenario<br>
where they might not be?<br>
<font color="#888888">--<br>
</font><div><div></div><div class="h5"><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>