Skip to content

Commit 2c928a2

Browse files
authored
Merge pull request Gepetto#29 from TheoMF/load_run_#2
new magic command to load and run
2 parents 1fcf440 + 2ec9a7e commit 2c928a2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: gepetuto/magic.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ class DoNotLoadMagics(Magics):
99
force_load = False
1010

1111
@line_magic
12-
def do_not_load(self, line):
12+
def do_not_load_snippet(self, line):
1313
"""Magic command to hide the snippet and let the student code by themself."""
1414
if DoNotLoadMagics.force_load:
15+
get_ipython().run_line_magic("run", "-i " + line)
1516
get_ipython().run_line_magic("load", line) # noqa: F821
1617

1718
@line_magic
@@ -24,6 +25,12 @@ def force_load(self, line):
2425
DoNotLoadMagics.force_load = False
2526
print("Force load is OFF")
2627

28+
@line_magic
29+
def load_snippet(self, line):
30+
"""Magic command to load and run the snippet, this only work on JupyterLab."""
31+
get_ipython().run_line_magic("run", "-i " + line)
32+
get_ipython().run_line_magic("load", line)
33+
2734

2835
ip = get_ipython() # noqa: F821
2936
ip.register_magics(DoNotLoadMagics)

0 commit comments

Comments
 (0)