简体   繁体   中英

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 ? 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?

Yes, you will get the default arguments in the call to func2 if func1 doesn't get them.

But be aware that of there are more arguments that func2 doesn't have, then you will have an error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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