On Mon, Dec 13, 2021 at 11:29 AM MRAB <pyt...@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
_______________________________________________
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/B2IEQJTE7GYLOQN2BQIUXOLUWDKV6FLX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to