An anonymous function (until I named it). The designers didn't want results that didn't have a pic_square.
req_pic = lambda list: [f for f in list if 'pic_square' in f and f['pic_square'] ]
So, when I'm loading up my dict I can make a check on the list:
result_dict['no_connect'] = req_pic( fb_no_connect )
That list was derived from pyfacebook.
fb_no_connect = fb.users.getInfo( [ int(x) for x in no_connect_set ],
[ 'name', 'pic_square', 'profile_url', 'uid' ])
I'm really finicky about when I use lambdas. Heck, for a while I stopped using them (http://pydanny.blogspot.com/2007/07/lambdas-no-more.html). So do you need one here or can you be more verbose. ;)
Is this really as efficient? Do you have a better solution?
def req_pic(li):
result = []
for f in li:
if 'pic_square' in f and f['pic_square']:
result.append(f)
return result