Login or Sign up

lambda list comprehension, python functional craft

Posted by: skyl on Oct. 9, 2009

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' ])

Comments on This Post:

Please Login (or Sign Up) to leave a comment