[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Dom Grigonis
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 a

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Chris Angelico
On Sun, 23 Jul 2023 at 14:08, Dom Grigonis 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 d

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Dom Grigonis
IT IS AN OBJECT. Never said otherwise. `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 contin

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Chris Angelico
On Sun, 23 Jul 2023 at 12:20, Dom Grigonis wrote: > > > > There is no way to have a value that isn't a value, in Python. The > > concept doesn't make sense and would break all kinds of things. > > (That's why, when a special function like __getitem__ has to be able > > to return literally anything

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Dom Grigonis
> There is no way to have a value that isn't a value, in Python. The > concept doesn't make sense and would break all kinds of things. > (That's why, when a special function like __getitem__ has to be able > to return literally anything, it signals "nothing to return" by > raising an exception.)

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Chris Angelico
On Sun, 23 Jul 2023 at 09:15, Dom Grigonis wrote: > This works ok: > > ``` > def foo(bar=None): > if bar is None: > bar = A() > > class A: > pass > ``` > > If PEP is aiming to replace the latter example, then it would be great if it > kept all of its advantages. I.e. not having to

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Dom Grigonis
1. Not if it is exactly as described in PEP. 2. No. 3. - 4. Couple of points here. One check and one orthogonal idea, which would make this PEP very attractive to me. I would definitely like use this functionality if both of below points were satisfied/achievable. If any of those weren't satisfi