MCPcopy Create free account
hub / github.com/ipython/ipython / store_or_execute

Method store_or_execute

IPython/terminal/magics.py:43–57  ·  view source on GitHub ↗

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

(self, block, name)

Source from the content-addressed store, hash-verified

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