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

Ville Vainio vivainio at kolumbus.fi
Sun May 15 10:50:16 EDT 2005

On Fri, 2005-05-13 at 14:49 -0600, Fernando Perez wrote:

> > Yeah, but it's still "magic system". It could be just a bunch of normal
> > python objects, visible normally, without a need to lookup a special
> > dictionary of magic methods (and another for aliases, etc.).
> Well, I still think it's worth making them special and isolated, for a number 
> of reasons:
> - I don't want to pollute the user's namespace with these names.  Currently 

Perhaps different kinds of callables (magics, aliases, etc.) could be
put in different modules, and the interactive prompt would just do a
search of a list of modules in a configurable order when the command
starts with a name that is not immediately visible.

> - Currently, %who shows you a clean namespace when you start, without a 
> zillion aliases/magics.  Do you really want to wade through a list of 3000 
> aliases every time you want to see what variables you've defined?

(covored by modules).

> - Magics behave like command-line utilities: --switch for options, whitespace 
> separating arguments.  I want to make it even easier to write new magics by 
> exposing the option-handling machinery.  This is part of what makes them 
> convenient to use, since there's a lot less typing of commas, parens and quotes.

Solved by adding meta-information to the actual callables on how to pass
the command line to the callable. A "magic" is just a callable that
takes one argument, a string. It doesn't need to be any more special
than that.

In the module it could be minimally declared as

def magickstuff(s):

and the ipy_magic decorator injects the necessary machinery to mangle
the command line before the actual function receives it.

More information about the IPython-dev mailing list