I think the question is, how is that fundamentally different than the value "None". Once you create this "special value", some function will decide to make it have a meaning as a passed in value, and then need a DIFFERENT "special value" as a default.

On 7/23/23 1:13 AM, Dom Grigonis wrote:
Or maybe you are not listening to what I am saying.

It would only take effect for arguments, which have default value.

So.
dict().__setitem__(key, NotGiven)
type(NotGiven)
Exception(NotGiven)
getattr(NotGiven, name)

Ok, maybe there are some crucial functions, which have argument defaults. But 
again, there is another solution then, implement efficient decorator in 
standard library, maybe as part of sentinels, maybe as part of your PEP, maybe 
separately.

I never said that it isn’t hard to write low-level python code. I will do that 
when the time is right for me. And I am not claiming that it is possible. If 
you read my language, all of my doubts are clearly expressed. You just seem to 
read everything as black and white even when it is not so.

However, such statements are in no way valid arguments in such discussion. If 
my idea is not optimal, not necessary, no-one needs it or any other valid 
responses, why it is not a good one - I can accept it.
But commenting that “it makes no sense” without properly explaining to me why 
after giving it some thought - it’s not fair.

Also, if you looked at things from a bit more positive perspective, maybe you 
could come up with some nice new ways how it could be done. Maybe not exactly 
what I am proposing, but some alternative, which would make it work. Most 
likely something much better than I am proposing.

After all, I am trying to see how your PEP can be improved, because if it could 
be used in all cases, where None can be, then at least to me, it would be a 
no-brainer to use it instead and to adapt it as best practice.

DG

On 23 Jul 2023, at 07:35, Chris Angelico <ros...@gmail.com> wrote:

On Sun, 23 Jul 2023 at 14:08, Dom Grigonis <dom.grigo...@gmail.com> wrote:
IT IS AN OBJECT. Never said otherwise.
One that you can't do any of the operations I described. There is no
way to use it as an object.

`inspect.getcallargs` can seemingly be modified for such behaviour. I just 
wrote a decorator, which does what I proposed using `inspect` module for a 
chosen sentinel value. The issue is that it would be a bottleneck if used on 
any callable, which is continuously used. `inspect.getcallargs`, `signature`, 
`getfullargspec` are very expensive.

If that can be done, theoretically it should be able to be done at lower level 
as well. After all, behaviour of it should be modelled after what is happening 
at the function call.

Since you clearly are not listening to the discussion, I will leave
you with one final recommendation: Write some code. Don't just claim
that it's possible; write actual code that makes it happen. You will
discover exactly how hard it is. If I am wrong, you will be able to
PROVE that I am wrong, instead of merely claiming it.

ChrisA

--
Richard Damon

_______________________________________________
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/JEIZYDJGK3RDW77FNZX5TZUP47JJT4XW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to