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.

1 Answer 1

2

You can use star unpacking:

session = ccrlib.CCRSession(*ccrlib.getauth())
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but I just figured it out a few seconds ago :/ Why is it that I never get the hard questions answered? facepalm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.