On Wed, Oct 27, 2021 at 8:06 AM Erik Demaine <edema...@mit.edu> wrote:
> I wonder if it would make sense to offer a "missing argument" object (builtin?
> attribute of inspect.Parameter? attribute of types.FunctionType?) that
> actually simulates the behavior of that argument not being passed.  Let me
> call it `_missing` for now.  This would actually make it far easier to
> accomplish "pass in the second argument but not the first", both with early-
> and late-binding defaults:
>
> ```
> f(_missing, {'more'})
> g(_missing, {'more'})
> ```
>
> I started thinking about `_missing` when thinking about how to implement
> late-binding defaults.  It's at least one way to do it (then the function
> itself could even do the argument checks), though perhaps there are simpler
> ways that avoid the ref count increments.
>

The trouble with sentinel values is that you always need another one.
Sooner or later, you're going to need to talk about the _missing
object, and you'll need to distinguish it from the absence of an
object.

If there is a way to say "don't pass this argument", it would have to
be some kind of syntactic token.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MSAWB5ZYZZOKYQ3JSC7C7Q2FK5PEVG4G/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to