MCPcopy Index your code
hub / github.com/ipython/ipython / store_or_execute

Method store_or_execute

IPython/terminal/magics.py:44–58  ·  view source on GitHub ↗

Execute a block, or store it in a variable, per the user's request.

(self, block, name, store_history=False)

Source from the content-addressed store, hash-verified

42 super(TerminalMagics, self).__init__(shell)
43
44 def store_or_execute(self, block, name, store_history=False):
45 """ Execute a block, or store it in a variable, per the user's request.
46 """
47 if name:
48 # If storing it for further editing
49 self.shell.user_ns[name] = SList(block.splitlines())
50 print("Block assigned to '%s'" % name)
51 else:
52 b = self.preclean_input(block)
53 self.shell.user_ns['pasted_block'] = b
54 self.shell.using_paste_magics = True
55 try:
56 self.shell.run_cell(b, store_history)
57 finally:
58 self.shell.using_paste_magics = False
59
60 def preclean_input(self, block):
61 lines = block.splitlines()

Callers 4

cpasteMethod · 0.95
pasteMethod · 0.95

Calls 3

preclean_inputMethod · 0.95
SListClass · 0.90
run_cellMethod · 0.45

Tested by 2