Thursday, 8 August 2013

Python dict call function as value

Python dict call function as value

I'm creating a dict in python using returned json.
one of the values I want to be a shortuuid, so I put a function as the
value. I want that function called and the value replaced with what that
function returns.
Is this correct ?
tvMSG = {'fromEMAIL': uEmail, 'toCHANNELID': channelID,
'timeSENT': uTime}
for msgkey, subdict, instakey in (('profilePIC', 'user',
'profile_picture'),
('userNAME', 'user', 'username'),
('msgBODY', 'caption', 'text'),
('mainCONTENT','images', 'standard_resolution',)
('tvshowID', shortuuid.uuid())):
this is the key/value in question:
('tvshowID', shortuuid.uuid())):
This is the error I get:
TypeError: 'tuple' object is not callable
If not how do I make it work?

No comments:

Post a Comment