Skip to content

Commit 3dc10f4

Browse files
committed
Simplify autoreload IPython script
* Avoids try...except statement, just use if clause * Create an instance with `get_ipython()` * Set autoreload 2 to load a module when it has been changed
1 parent 3b8c92b commit 3dc10f4

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

.ipython/profile_default/startup/10-autoreload.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#
2-
try:
3-
get_ipython().run_line_magic("load_ext", "autoreload")
4-
get_ipython().run_line_magic("autoreload", "-p", "1")
1+
from IPython.core.getipython import get_ipython
2+
3+
ipython = get_ipython()
4+
5+
if ipython is not None:
6+
ipython.run_line_magic("load_ext", "autoreload")
7+
ipython.run_line_magic("autoreload", "2")
8+
59
print(" Automatically enabled autoreload")
6-
except Exception:
7-
pass # Not running inside IPython

0 commit comments

Comments
 (0)