3

Its perhaps not the safest thing in the world to do, but assuming risks have been accounted for, what's the simplest way to load an run a python script that is http(s) hosted, from the local machine?

1 Answer 1

4
# python 2
from urllib import urlopen
# python 3
from urllib.request import urlopen

page = urlopen('https://DANGEROUS').read()
exec(the_page)

EDIT: @jakekimds was right to point out that exec is more appropriate than eval here.

Sign up to request clarification or add additional context in comments.

2 Comments

exec is better for this purpose.
That said, what is your expected use-case? Most use-cases should be possible without eval/exec.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.