With these it helps I don't know the OperationsRig class definition, so I define one by myself. Since it could successfully match, I think it is not the problem of pyqt.
def foo(self, msg):
print('foo:' + str(msg))
return 'foo OK'
def foo1(self, msg):
print('foo1:' + str(msg))
return 'foo1 OK'
opr = OperationsRig()
# Text gives me the name to Match ------------------#
# have 3 ways of getting the class instance methods into a list to iterate ..
method_list = [func for func in dir(opr) if callable(getattr(opr, func))]
# This var is a list to pass to the Method
Sel_list = [1,2,3]
# iterate over the "self.OperationsRig" methods
""" option 1 """
for meth in method_list:
if text.strip().lower() in meth.lower()[:]:
# if match, and it does, will call the class method and send the data.
return getattr(opr, meth)(Sel_list) # Executes the funcion instance, but is not
# sending the data, I've checked printing inside.
# NoneTypeObject is not iterable. no data sent.
foo:[1, 2, 3]
foo1:[1, 2, 3]
Process finished with exit code 0
How to distinguish an instance method, a class method, a static method or a function in Python 3?
By : Praphul Dn
Date : March 29 2020, 07:55 AM
will help you You just need to get the type of the method, but since methods are descriptors, you have to : 1 - Get the class out of the instance. 2 - Look up the method reference in __dict__ instead of making an attribute lookup.