Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to put already defined vars and values into Python dict?
    primarykey
    data
    text
    <p>I have this code:</p> <pre><code>if 'instagramTV' in path: self.send_response(200) instaShortcode, LTV, EMAIL, TIME, userID, URL = map(\ qs.get, ['instaID', 'channelID', 'uEmail', 'Time', 'uID', 'contentUrl']) channelID, uEmail, instagramShortcode, uTime, uID, contentUrl = map(\ lambda x : str(x)[2:-2], [LTV, EMAIL, instaShortcode, TIME, userID, URL]) for i in (channelID, uEmail, instagramShortcode, uTime, uID, contentUrl): print i instaSTEP2 = requests.get("http://api.instagram.com/oembed?url=http://instagr.am/p/%s/"% instagramShortcode).json() instaMeID = instaSTEP2['media_id'] instaINFO = requests.get("https://api.instagram.com/v1/media/%s?accesstoken=295391286.1b882b8.33fa51373fae4885b5c60ceb186e6560" % instaMeID).json() print instaINFO['data']['user']['profile_picture'] print instaINFO['data']['user']['username'] print instaINFO['data']['caption']['text'] print instaINFO['data']['images']['standard_resolution']['url'] ltvMSG = {'fromEMAIL': 'uEmail', 'toCHANNELID': 'channelID', 'timeSENT': 'uTime', 'profiePIC': "instaINFO['data']['user']['profile_picture']",'userNAME': "instaINFO['data']['user']['username']", 'msgBODY': "instaINFO['data']['caption']['text']", 'msgIMAGE': "instaINFO['data']['images']['standard_resolution']['url']"} print ltvMSG </code></pre> <p>First vars come in from a http get request, then I use some of those vars to make a api call, then I get back some json. </p> <p>I'm trying to put some of the initial vars from the get request and some values from the api call into my own dict/json which eventually will go into a redis list.</p> <p>print ltvMSG returns this:</p> <pre><code>{'userNAME': "instaINFO['data']['user']['username']", 'timeSENT': 'uTime', 'msgIMAGE': "instaINFO['data']['images']['standard_resolution']['url']", 'msgBODY': "instaINFO['data']['caption']['text']", 'fromEMAIL': 'uEmail', 'toCHANNELID': 'channelID', 'profilePIC': "instaINFO['data']['user']['profile_picture']"} </code></pre> <p>This is the structure I want but how do I make the real values appear as values to the keys.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload