fun_connect_main() missing 1 required positional argument: 'self'
调用类的方法时,注意不同的状态。
调用类的实例方法,
1、无参数时,如果没有直接实例该类,必须加:self;
或者在调用方法时,提前定义这个类的实例,才能直接调用该类的实例方法。
2、有参数时,也要加self,必须加后面的参数。
调用类的静态方法,不用加self,跟据参数匹配进行调用。
调用类的类方法时,根据参数匹配即可。
Passing mainController.MainLogic instead of SerialControl.MySerialControl. Is this intentional? less... (Ctrl+F1)
Inspection info: This inspection checks for calls of a method by class while passing an instance of a different class as self parameter:
foo = Foo()
Bar.baz(foo, *more)
Sometimes this may be intentional and correct. But when unintentional, this leads to subtle bugs.
有时这可能是有意和正确的。但是,当无意识的时候,这会导致细微的bug。
总结:
规范用法:调用类的实例方法一般要先实例化该类。
快速用法:直接加self,即在self对应的类实例化了。