简体   繁体   English

如何使用kwargs自动完成功能参数?

[英]How to have autocomplete in function parameters with kwargs?

def func1(param_0, **kwargs):
    if param_0:
        return func2(**kwargs)
    else:
        return func3()

def func2(param_1 = 1, param_2 = 2):
    print("func2", param_1, param_2)

def func3():
    print("func3")

If I have a piece of code like this, is that possible to have parameter name autocomplete for param_1 and param_2 when calling func_1 ? 如果我有一段这样的代码,在调用func_1时是否可以为param_1param_2设置参数名称自动完成? That said, in Jupyter notebook or PyCharm or something similar, do I need to manually type in eg param_1 or I could use tabs for autocompletion? 就是说,在Jupyter笔记本电脑或PyCharm或类似产品中,我是否需要手动输入例如param_1或可以使用选项卡进行自动完成?

Yes, you will get the default arguments in the call to func2 if func1 doesn't get them. 是的,如果func1没有获得默认参数,您将在对func2的调用中获得默认参数。

But be aware that of there are more arguments that func2 doesn't have, then you will have an error. 但是请注意, func2没有更多的参数,那么您将遇到错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM