Last active
August 29, 2015 14:15
-
-
Save carsonfarmer/a6289e769c793efee1ba to your computer and use it in GitHub Desktop.
A simple function that fetches a remote (or local) python file and runs it inside an IPython Notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_remote_code(url): | |
"""Fetch and run remote Python code. | |
This is a custom function that fetches | |
and runs remote Python code inside of an | |
IPython Notebook. | |
Careful, this could be super bad stuff! | |
""" | |
from IPython.core.magics.code import CodeMagics | |
cm = CodeMagics(get_ipython()) | |
code = cm.shell.find_user_code(url) | |
return cm.shell.run_code(code) | |
get_remote_code("http://example.com/python_code.py") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment