0

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.

polandeer
  • 396
  • 4
  • 16

1 Answers1

2

You can use star unpacking:

session = ccrlib.CCRSession(*ccrlib.getauth())
ecatmur
  • 152,476
  • 27
  • 293
  • 366
  • Thanks, but I just figured it out a few seconds ago :/ Why is it that I never get the hard questions answered? *facepalm* – polandeer Aug 16 '12 at 15:57