From 6f72c481d1ff486d5287532cebc485f5f9a59be6 2008-09-13 07:51:02 From: Ville M. Vainio Date: 2008-09-13 07:51:02 Subject: [PATCH] %edit: doing %edit pasted_block will store new value for pasted_block (originally created by %cpaste) --- diff --git a/IPython/Magic.py b/IPython/Magic.py index feccfcf..1fe3b29 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -2329,6 +2329,12 @@ Currently the magic system has the following functions:\n""" print 'Editing...', sys.stdout.flush() self.shell.hooks.editor(filename,lineno) + + # XXX TODO: should this be generalized for all string vars? + # For now, this is special-cased to blocks created by cpaste + if args.strip() == 'pasted_block': + self.shell.user_ns['pasted_block'] = file_read(filename) + if opts.has_key('x'): # -x prevents actual execution print else: @@ -2338,6 +2344,8 @@ Currently the magic system has the following functions:\n""" else: self.shell.safe_execfile(filename,self.shell.user_ns, self.shell.user_ns) + + if use_temp: try: return open(filename).read()