Skip to content

Instantly share code, notes, and snippets.

@carsonfarmer
Last active August 29, 2015 14:15
Show Gist options
  • Save carsonfarmer/a6289e769c793efee1ba to your computer and use it in GitHub Desktop.
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
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