Execute a block, or store it in a variable, per the user's request.
(self, block, name, store_history=False)
| 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() |