[IPython-dev] Closing in on 0.11? We need some review/feedback help
Sat Jan 16 23:48:01 CST 2010
On Thu, Jan 14, 2010 at 5:49 PM, Fernando Perez <firstname.lastname@example.org>wrote:
> Hi Gokhan,
> On Wed, Jan 13, 2010 at 2:48 PM, Gökhan Sever <email@example.com>
> > Ahaa, here is one catch (some extra outputs in whos listing --which I was
> > going to ask if it is possible to list the command that we used to
> > a object next the Data/Info column in whos listing?
> > Sometimes I search my history to see how I constructed an object. That
> > be useful to have it listed on a whos listing.
> There is no way to know this in python in general, since multiple
> names can be bound to one object, assignments can happen in many
> different ways (code can write to namespace dicts directly, etc). But
> you can write a little extension of yours that walks the In input
> history list looking for things that look like variable assignments.
> It won't be very robust, but could be useful. If you end up liking
> it, put it up on the cookbook and we can ship it later as an optional
> tool, once you've stress-tested it.
Here is my idea to implement this following your %history suggestion:
1- Look in the history in the reverse order to obtain the latest entry of
the same variable assignment. Each element listed in the history output is a
separate string pulled out of a list.
2- Compare the "string".split("=") with each variable name in %whos call.
3-Write the output in the 4th column of the whos listing (using a one of the
names: "Assignment", "Command", "History"):
Variable Type Data/Info Assignment
a int 5 a=5
n float 0.0 n = math.sin(0)
Data/Info column usually produces longer lines this might cause some ugly
Could I get some suggestions?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev