[IPython-dev] Namespace pollution and a kernel panel

Bob McElrath bob+ipython at mcelrath.org
Fri Jun 15 16:31:35 EDT 2012

One of my long-standing complaints about notebook-style worksheets (Maple,
Mathematica) is the large and hidden namespace of defined symbols.  If one is
not careful, it's easy to end up with some element of worksheet-state that is
not what you think it is, and end up with garbage results.  This can be very
difficult to track down.  And because worksheets are generally not executed top
to bottom, it often results in difficult-to-reproduce errors.

I discovered this today with IPython's notebook and gamma(), which turns out to
be numpy.random.gamma() rather than the Euler Gamma function math.gamma() or

This is because I ran ipython --pylab, but it highlights a bigger problem: how
does the user know which symbols are defined?  I have been thinking lately of an
addition to the notebook interface: a side-panel showing everything
defined/imported in the kernel.  This would further allow the user to inspect
the output of commands by clicking on kernel data structures, rather than
wasting a cell just to print some output.  Personally I always end up with very
messy worksheets, because I insert a lot of print or plot commands, just to
explore a data structure or function.

Another possible use of such a thing would be a non-modifying cell: a cell that
refuses to change the state of the kernel by modifying variables, but could be
used to print/plot/explore existing data structures.  Then when one has found
the most desirable representation, that could be copied/moved to the worksheet.

Perhaps there are other creative ways to avoid the user having to manage an
approximation of the kernel state in their head.

Cheers, Bob McElrath

"The individual has always had to struggle to keep from being overwhelmed by
the tribe.  If you try it, you will be lonely often, and sometimes frightened.
But no price is too high to pay for the privilege of owning yourself." 
    -- Friedrich Nietzsche

More information about the IPython-dev mailing list