Allow %loadpy to load remote URLs that don't end in .py #1161

merged 5 commits into from Dec 16, 2011


None yet

2 participants

fperez commented Dec 15, 2011

Will also fix same encoding bug we found for notebooks next.

@takluyver takluyver commented on an outdated diff Dec 15, 2011
@@ -2151,7 +2151,11 @@ def magic_loadpy(self, arg_s):
arg_s = unquote_filename(arg_s)
- if not arg_s.endswith('.py'):
+ if not arg_s.startswith(('http://', 'https://')) \
+ 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
raise ValueError('%%load only works with .py files: %s' % arg_s)
if arg_s.startswith('http'):
takluyver Dec 15, 2011 Member

Don't forget to change this one as well (same issue with local files like '')

fperez commented Dec 16, 2011

Reviewed by @takluyver and @minrk on IRC in addition to what's here, merging now.

@fperez fperez closed this Dec 16, 2011
@fperez fperez merged commit 3deb45e into master Dec 16, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment