首页 > 解决方案 > Pycharm 热键/设置将 *args 调用更改为 **kwargs 调用

问题描述

假设我想覆盖__init__它的后代中的某个类,即

class Parent:
    def __init__(self, arg1, arg2, arg3):
       ...
    ...

class Child(Parent):
    def __init__(self, arg1, arg2, arg3):
        super().__init__(arg1, arg2, arg3)
        ...

如果我创建子类,然后按下Ctrl+O并选择覆盖__init__PyCharm 将生成类似上述代码的内容。但我想用**kwargsinit 而不是调用父级*args

# instead of this
# super().__init__(arg1, arg2, arg3)
# I want this (by settings/hotkey)
super().__init__(arg1=arg1, arg2=arg2, arg3=arg3)

有什么建议么?

标签: pythonpycharmhotkeys

解决方案


推荐阅读