获取函数参数作为字典 - python

我知道* arg,** kwarg有很多问题/答案。但是,我正在做一些向后的操作,但找不到解决的方法(也许我只是不知道如何问这个问题。)无论如何,我想简化以下内容:

def foo(self, arg1, arg2, arg3):
     my_dict = dict(arg1=arg1, arg2=arg2, arg3=arg2)
     my_str = "{arg1} went up the {arg2} hill to fetch a pail of {arg3}".
               format(**my_dict)

注意,我不希望将foo定义为(self,** kwargs),因为我喜欢填写函数的自动完成组件。

谢谢,

python大神给出的解决方案

这些参数位于本地名称空间dict中,因此请使用它:

def foo(self, arg1, arg2, arg3):
     my_str = "{arg1} went up the {arg2} hill to fetch a pail of {arg3}".
               format(**locals())