<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, 2 Mar 2017 at 08:58 Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 03/02/2017 08:13 AM, Joao S. O. Bueno wrote:<br class="gmail_msg">
<br class="gmail_msg">
> Is it just me that find that having the un-assigned parameter raise<br class="gmail_msg">
> NameError (or other exception) much more cumbersome than<br class="gmail_msg">
> havign a sentinel-value?<br class="gmail_msg">
<br class="gmail_msg">
No. While clever, the hassle of figuring out if you have a parameter clearly outweighs the benefit of avoiding a<br class="gmail_msg">
sentinel value.<br class="gmail_msg">
<br class="gmail_msg">
It would be a different story if we had exception-catching expressions. ;)<br class="gmail_msg"></blockquote><div><br></div><div>I don't like the NameError solution either.</div><div><br></div><div>What I would like to know is how common is this problem? That will help frame whether this warrants syntax or just providing a sentinel in some module in the stdlib that people can use (e.g. functools.NotGiven; I do prefer MAL's naming of the sentinel). Sticking it into a module would help minimize people from using it in places where None is entirely acceptable and not confusing the whole community when people suddenly start peppering their code with NotGiven instead of None for default values.</div><div><br></div><div>And if this is really common enough to warrant syntax, then I would want:</div><div><br></div><div> def foo(a, b, opt?): ...</div><div><br></div><div>to represent that 'opt' is optional and if not provided by the user then it is given the value of NotGiven (or None if we are just after a syntactic shortcut to say "this argument is optional").</div><div><br></div><div>So to me, there's actually two things being discussed. Do we need another sentinel to handle the "None is valid" case, and do we want syntax to more clearly delineate optional arguments?</div></div></div>