[IPython-dev] Towards IPython 1.0, the famous big cleanup
Fernando.Perez at colorado.edu
Fri Apr 15 14:27:31 EDT 2005
Ville Vainio wrote:
> On Thu, 2005-04-14 at 17:19 -0600, Fernando Perez wrote:
>>- the magic system will be fully overhauled. The core of your custom magics
>>will most likely run unchanged, but how they plug into ipython will change.
> I've probably said this before, but -
> Do we need a magic system at all?
> It would be cleaner if what are now "magic" would be just normal Python
> functions/callables, with some additional metadata about how it wants to
> receive the argument string. To behave exactly like magics (apart from
> separate namespace and %), it would just need to take a single string
> (the whole command line) as argument.
Well, that's pretty much what they do today. It's just that making a new
magic involves binding by hand an instance method with a special name, for
from IPython.iplib import InteractiveShell
def magic_runbatch(self, parameter_s=''):
""" runbatch magic command.
fileobj = open(parameter_s,'r')
print "Error: could not open file",parameter_s
InteractiveShell.magic_runbatch = magic_runbatch
What I envision, is something cleaner, more like:
And that's it. Any function you write can be made into a magic, as long as it
conforms to a minimal API. When I actually start working on this (probably
item #2 after the config system rewrite), I'll make sure to post my plan to
this list, so anyone with thoughts/criticisms can voice them early on before I
spend too much time coding myself into a silly corner.
> Shell commands would all refer to the same object, one that takes the
> whole command line and does the deed.
Again, today we pretty much have this already, it's just not cleanly indicated
But thanks for the comments: I _really_ want people to voice any and all
concerns or ideas they may have in this direction. I hope that when 1.0 comes
out, we can be reasonably happy that the publicly exposed API is stable enough
that users can rely on it for a while. So by all means, speak up!
More information about the IPython-dev