Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created April 1, 2018 20:25
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 ryo1kato/3bde54f929fd4bbeeac61db586eaefb3 to your computer and use it in GitHub Desktop.
Save ryo1kato/3bde54f929fd4bbeeac61db586eaefb3 to your computer and use it in GitHub Desktop.
ipython autoload
import sys, os, re
class AutoLoader():
def __init__(self, nickname, modulename):
self.nickname = nickname
self.modulename = modulename
def __getattr__(self, methodname):
g = globals()
g[self.nickname] = __import__(self.modulename)
return getattr(g[self.nickname], methodname)
pd = AutoLoader('pd', 'pandas')
np = AutoLoader('np', 'numpy')
plt = AutoLoader('plt', 'matplotlib.pyplot')
sns = AutoLoader('sns', 'seaborn')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment