Reputation: 396
So, I was wondering if it was possible to use the return information from one function as the parameters for another without using a variable. The function I am trying to use takes two parameters (and self because it's part of a class) and the other function returns two values. The best I can get is:
import ccrlib
authinfo = ccrlib.getauth()
session = ccrlib.CCRSession(authinfo[0], authinfo[1])
Otherwise I would have to run getauth twice:
import ccrlib
session = ccrlib.CCRSession(ccrlib.getauth()[0], ccrlib.getauth()[1])
Which is most obviously less efficient.
Upvotes: 0
Views: 61
Reputation: 157314
You can use star unpacking:
session = ccrlib.CCRSession(*ccrlib.getauth())
Upvotes: 2