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