[IPython-dev] Towards IPython 1.0, the famous big cleanup

Fernando Perez Fernando.Perez at colorado.edu
Fri Apr 15 13:44:17 CDT 2005


Jack Moffitt wrote:
>>magic involves binding by hand an instance method with a special name, for 
>>example:
>>
>>from IPython.iplib import InteractiveShell
>>
>>def magic_runbatch(self, parameter_s=''):
>>    """ runbatch magic command.
>>    """
>>    try:
>>        fileobj = open(parameter_s,'r')
>>    except:
>>        print "Error: could not open file",parameter_s
>>        return
>>    else:
>>        self.shell.runlines(fileobj.read())
>>
>>InteractiveShell.magic_runbatch = magic_runbatch
>>del magic_runbatch
>>
>>What I envision, is something cleaner, more like:
>>
>>__IPYTHON__.set_new_magic(your_function,optional_name='mymagic',opt_args=...)
> 
> 
> Not that I like the new decorator syntax, but something like:
> 
> @InteractiveShell.magicmethod
> def run_batch(...)
>    ...
> 
> Is pretty easy to read and grok.

Yup, but that's 2.4.  I'm trying to hold on to 2.2 compatibility for as long 
as I can.  That may be too much to ask, but definitely 2.3 will be a target, 
so 2.4-specific features may be out.

f




More information about the IPython-dev mailing list