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

Ville Vainio vivainio at kolumbus.fi
Fri Apr 15 11:57:52 CDT 2005


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. 

Shell commands would all refer to the same object, one that takes the
whole command line and does the deed.

Other command line metadata information could be added to provide
alternative completion mechanisms - for example 'cd' might only show
dirs as filename completions (a contorted example):

@ipy_func_completers(ipy_isdir_completer)
def cd(path):
	os.chdir(path)


A 'sendmoney' func always interprets the first arg as string, w/o need
to quote:


@ipy_argtypes(str,int)
def sendmoney(recipient, amount):
	pass


sendmoney ville,10000 # works
sendmoney "ville vainio",10000 # also works

Of course the system could be extended indefinitely this way.




More information about the IPython-dev mailing list