6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

.pyファイルの再import

Last updated at Posted at 2015-05-05

概要

IPython Notebook等でmoduleの読み込みだけしてコード自体は別のテキストエディタで編集しているときに2回目以降のimportが効かなかったのでメモ。

解決策

sys.modulesから読み込みたいモジュールを消す。

fuga.py
import sys
try:
    del sys.modules['hoge']
except Exception as e:
    pass
import hoge
6
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?