Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My one objection to this is the `imp` module. As far as I can tell it is the only way (short of `sys.path` modification) to specifically load a module found at a specific path. For testing systems I use this quite extensively... Looks like I need to make some comments...


You can do that with importlib too:

    from importlib.machinery import SourceFileLoader


That's been deprecated as well. The current docs say you should do this

    spec = importlib.util.spec_from_file_location(module_name, file_path) 
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
https://docs.python.org/3/library/importlib.html#importing-a...


Gross...


I use imp.reload(my_module) all the time when %run-ing things from ipython that import my_module after editing it. What's the alternative for that use?


Using importlib.reload


In[1]: %load_ext autoreload In[2]: %autoreload 2

?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: