Reputation: 41
so I am trying to use the requests module to make an auto-updater for my program. I want to take the text from a Pastebin file and use that as my code. This is what I've done so far.
import requests
coderaw = requests.get('https://pastebin.com/raw/s3d1kWgu')
code = coderaw.text
So I want the "code" variable to be my source code. Does anybody know a module or an operator that lets me do this?
Thanks.
Upvotes: 0
Views: 58
Reputation: 1631
You can use exec to execute the code in coderaw, for example:
my_code = 'print ("Hello World!")'
exec(my_code)
Using your code:
import requests
coderaw = requests.get('https://pastebin.com/raw/s3d1kWgu')
code = coderaw.text
exec(code)
Upvotes: 1