[IPython-user] Feature suggestion: %remember
Fernando Perez
Fernando.Perez at colorado.edu
Thu Dec 8 12:07:06 CST 2005
Ville Vainio wrote:
> Here's an idea that is rather easy to implement: a new magic called
> %remember. It would store the name & value of the specified variable
> to the same persistent_data structure as bookmarks, and all the values
> in that structure would be loaded to the appropriate variables at
> session startup.
The problem is that pickle is notoriously finicky, and there are many
innocuous-looking things in python which can NOT be pickled, so this function
can fail at any time.
One could certainly write an implementation which tiptoes through the list of
things to remember, tries to pickle each and reports upon exit which ones
failed to write. But I'm not sure how useful such an unreliable tool would
be, and with ipython I always resist putting in the core something which is
too easy to break in everyday use.
On the other hand, this is precisely the kind of thing that you could keep in
your personal config: since you know its limitations, you can use it well.
And I'd be happy to keep a collection of such 'personal toys' in the public
ipython wiki, since they would most likely only be used by more experienced
users, and there would be a message indicating their limitations.
So if you write it for your own purposes, by all means send it and I'll put it
up on the wiki. But until you can convince me that we can have this in the
core and be _reliable_, I'm afraid I'll balk at it.
Cheers,
f
ps - implementation tips: use shelve, atexit, and in your magic, store the
list of names to be rememberd as a hidden var in the user namespace:
self.shell.user_ns['__magic_remember'] = ....
With these, the actual implementation should be very, very easy (if not robust
due to the problems listed above).
More information about the IPython-user
mailing list