I have a list d of 'tokens' all strings and a list of tuples of the form (fieldname,fieldtype) For Example
ds = ['1','1','1','1','1']
fs = [('type',str),('value',int),('hidden',bool),('length',int),('pieces',str)
and I want to make a dict v having the following form
v = {'type':'1','value',1,'hidden':True,'length':1,'pieces','1')
What I currently have is very inefficient (I map the type func in the tuple to elements in the list one at a time)
v = {}
for j in xrange(len(fs)):
v[fs[j]] = map(fs[j][1],[ds[j]])[0]
How can I make this efficient and easy to read? I've tried lambdas, etc. If this were a one time thing I would just do it manually but there are multiple lists of tuples some of them 50 elements long.