2

I've been messing around with an API for a trading website. I'm looking to reduce the amount of calls I have to make (via JSON) to the website so I figure I will assign the results of my call to a variable. My question is this:

ETH_balance = polo.return_balances('ETH')
BTC_balance = polo.return_balances('BTC')

If I assign the API call polo.return_balances('ETH') to ETH_balance, is the variable ETH_balance storing the result of the call or the actual call itself?

Does it hinge on if the API call return's the result?

8
  • 3
    Always the result. Commented Jun 9, 2017 at 19:16
  • 1
    Result of call. The () is an operator in python. Commented Jun 9, 2017 at 19:16
  • 2
    If you want to assign a function call to a variable, you use a lambda Commented Jun 9, 2017 at 19:16
  • Thanks guys, much appreciated. Commented Jun 9, 2017 at 19:16
  • 1
    @Barmar or better yet, a full function definition, since assigning lambdas to names is explicitly recommended against in PEP8. Commented Jun 9, 2017 at 19:17

1 Answer 1

1

It will store the result of the call.

You can assign functions to variables in python however that will do nothing to reduce the number of calls you are making to the API.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't understand, if it stores the result and I use the variable ETH_Balance later on, shouldn't it return the result of the call and not call the function again?
It will use the result of the function call, sorry I should have made that more clear.

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.