I'm grabbing a list from a website using their API and saving it as variable "playlistNames". In a later function when I call "playlistNames" to manipulate the data, is it making another API call? or is the data just stored locally in the "playlistNames" variable?
Sorry for such a silly question, I can't seem to google this properly.
CodePudding user response:
If you saved the API response to a variable, it won't call the API every time you access that variable.
r = requests.get("https://google.com")
print(r.text) # doesn't call again...
print(r.status_code) # doesn't call again...
CodePudding user response:
If you are running the entire script where you wrote the API request and the execution passes through it every time you run it, it will call it. Otherwise it will run it from the saved variable assuming you are on the same kernel.
