Skip to content

Instantly share code, notes, and snippets.

@fperez
Created December 15, 2011 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fperez/1483383 to your computer and use it in GitHub Desktop.
Save fperez/1483383 to your computer and use it in GitHub Desktop.
IPython impromptu PR
diff --git a/IPython/core/magic.py b/IPython/core/magic.py
index ee84680..f82b43f 100644
--- a/IPython/core/magic.py
+++ b/IPython/core/magic.py
@@ -2151,7 +2151,10 @@ Currently the magic system has the following functions:\n"""
%loadpy http://www.example.com/myscript.py
"""
arg_s = unquote_filename(arg_s)
- if not arg_s.endswith('.py'):
+ if not arg_s.startswith('http') and not arg_s.endswith('.py'):
+ # Local files must be .py; for remote URLs it's possible that the
+ # fetch URL doesn't have a .py in it (many servers have an opaque
+ # URL, such as scipy-central.org).
raise ValueError('%%load only works with .py files: %s' % arg_s)
if arg_s.startswith('http'):
import urllib2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment