I have this code:
def get_endpoint(type):
return "%s/%s.json" % (v2_endpoint,type)
def get_entities(type,endpoint=None,entities=None):
if not endpoint:
endpoint=get_endpoint(type)
entities=[]
r=requests.get(endpoint,headers=header)
entities.extend(r.json()[type])
if not 'next' in r.links:
return entities
else:
return get_entities(type,r.links['next']['url'],entities)
print "Fetching info from New Relic....",
servers = get_entities('servers')
applications = get_entities('applications')
print "Done."
I noticed that it doesn't print the first and last print statements until it has processed those functions. Expected behaviour, I presume.
So, how do I make it print the first line before it starts processing the function?