# -*- coding: utf-8 -*-
import os
import fbconsole
here = os.path.dirname(os.path.abspath(__file__))
def fbfeed():
fbconsole.APP_ID = '588914247790498'
fbconsole.AUTH_SCOPE = ['publish_stream', 'publish_checkins', 'read_stream', 'offline_access']
fbconsole.authenticate()
newsfeed = fbconsole.get('/me/home')
newsfeedData = newsfeed["data"]
for status in newsfeedData:
fromn = [status['from']['name']]
name = [status.get('name', None)]
description = [status.get('description', None)]
if description == name is None:
return fromn
elif description is None:
return fromn.extend(name)
elif name is None:
return fromn.extend(description)
else:
return fromn + name + description
My code returns only one string, but when I use print instead of return – it prints ALL of results. How can I return the same results, as in case of print??
When you use return it exits the function and doesn’t keep iterating through the loop like it does with print. Try yield.