Here is a quick and dirty proof of concept:

    from inspect import stack, Signature

    def parameters():
        caller = stack()[2][0].f_globals[stack()[1][3]]
        sig = Signature.from_callable(caller)
        vars = stack()[1][0].f_locals
        return sig.bind(**vars).arguments


    def func(spam, eggs):
        params = parameters()
        for name, value in params.items():
            print(name, '=', value)


Calling `func(2, 3)` prints:

    spam = 2
    eggs = 3


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

Reply via email to