<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 16, 2014 at 9:45 PM, Yury Selivanov <span dir="ltr"><<a href="mailto:yselivanov.ml@gmail.com" target="_blank">yselivanov.ml@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=""><br>
On 2014-04-16, 1:29 PM, Guido van Rossum wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
TBH I think it's usually an anti-pattern when you have an API where the<br>
absence of a parameter is not equivalent to some default value. It makes<br>
wrapping such APIs awkward, e.g.<br>
<br>
def logging_foo(*, arg1='something_other_than_<u></u>spam', arg3=None,<br>
arg4=<what???>):<br>
     <a href="http://loging.info" target="_blank">loging.info</a>('calling foo(arg1=%r, arg3=%r, arg4=%r)', arg1, arg3, arg4)<br>
     return foo(arg1=arg1, arg3=arg3, arg4=arg4)<br>
</blockquote>
<br></div>
Agree, wrapping is hard, but you can always use **kwargs.<br>
<br>
The pattern is sometimes useful for decorators (as Ryan Gonzalez<br>
shows in this thread). But basically, you need this when 'None'<br>
is a legitimate value for some optional argument, and you want<br>
users to pass explicitly.<br>
<br>
For instance, see inspect.Signature.replace method:<br>
<a href="http://hg.python.org/cpython/file/e4ee0b15cc4f/Lib/inspect.py#l2193" target="_blank">http://hg.python.org/cpython/<u></u>file/e4ee0b15cc4f/Lib/inspect.<u></u>py#l2193</a><br>
<br>
I'm not saying it's a very common thing to do, but sometimes<br>
you need this, and having the need of doing some ad hoc hacks<br>
is slightly annoying.</blockquote><div> </div><div>...but it would be yet another thing to learn.</div><div>Plus, being it uncommon you would easily forget what's the "right way to do it" and likely come up with the usual object() hack anyway.</div>

</div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Giampaolo - <a href="http://grodola.blogspot.com" target="_blank">http://grodola.blogspot.com</a></div><div><br></div></div>
</div></div>