Hacker News new | ask | show | jobs
by ijoshua 6641 days ago
Python‘s way of accomplishing this is as easy, although the use of `locals` should indicate that this isn’t generally something you should be doing:

    post = {'name': 'ijoshua', 'email': 'spam@example.com', 'extra': 'data'}
    
    filter = ['name', 'email']
    
    for k in filter: locals()[k] = post[k]
    
    print name, email