
On Mon, Dec 13, 2021 at 11:29 AM MRAB <python@mrabarnett.plus.com> wrote:
Hmm.
What about something like this as a bit of syntax:
def my_decorator(f): @wraps def wrapper(from my_decorator): return f(from my_decorator) return wrapper
The idea is that in a function's parameter list it would pick up the signature and in a function call it would pick up the arguments.
In the simple case, that's already done. Just use *a,**kw, and the wraps(f) decorator will mark it as "use the signature of that function over there". Unfortunately, that's only the simple case. You can't say "use the signature of that function, but I also accept this arg". You can't say "use the signature of that function, except that I don't accept this arg". But it would be theoretically possible to do exactly that using basically the inspect module, and it would be an extremely useful feature for many situations, especially if it can be automated in some way (eg if it notices "def f(spam, *a, **kw)" and adds spam to the parameter list). ChrisA