Your name is a bit confusing since you can really pass a method. Python functions are first class, which means you can pass them as any value.
However, your text indicates that you want to do something else.
Python really returns multiple values ββas a single value, a tuple of values.
return 1, 2
really the same thing
return (1, 2)
However, if you need to unpack these values, as in your case, there are several ways to achieve this.
You can unpack them into variables:
usn, psw = myObject.getAccount()
Or you can "expand" them directly in a function call:
myModule.logIn(*myObject.getAccount())
This requires the number of arguments to be the same as the size of the tuple (function 2 of the argument requires a tuple (x, y) )
If you want to pass a method, you can do it, but you need to be careful not to name it:
def logIn(self, a): usn, psw = a()
source share