Skip to content
This repository

%Store eliminated in configuration and magic commands in 0.11 #684

Closed
excetara2 opened this Issue August 06, 2011 · 15 comments

3 participants

excetara2 Thomas Kluyver Keith Solademi
excetara2

I had used in console the store command to store macros for multiple sessions. I noticed this has been removed in the console and in qtconsole in 0.11. I haven't seen anything to store macros persistently across sessions so I am guessing this is a regression that should have made it into 0.11 but didn't for one reason or another.

Thomas Kluyver
Collaborator

We do intend to restore %store or something equivalent before the next release, I think.

excetara2

That'd be great. Is there anything similar one can do now to keep macros between sessions. Like a function to declare a macro that could be loaded on ipython startup.

Cheers,
Jeff

Thomas Kluyver
Collaborator

If you use the new config files, and find exec_lines, you can store the code in a string and call %macro, something like this:

...exec_lines = ["""mymacrocode = "print 'Hello world!'" """,
                       """%macro mymacro mymacrocode"""]

I haven't tested this, but it should work. I don't think there's a way to interactive store a macro, though.

excetara2
Keith Solademi

I used store a lot. Guess I'm going back to the old ipython for now.

excetara2
Thomas Kluyver
Collaborator

Sorry no-one's got round to bringing it back yet. If either of you would like to work on it, you'll need to update the quarantined pspersistence module to the new API. Its current code is here:

https://github.com/ipython/ipython/blob/master/IPython/quarantine/pspersistence.py

We can of course provide more information if you want to ask questions on the mailing list.

excetara2
Thomas Kluyver
Collaborator

I'm not sure if there is a neat source for what changed, unfortunately. At a brief glance, I think the only thing that changes is how we register magics. Have a look at how it's done for history: https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L1875

Also, if you're interested in persistence, I wrote down a few thoughts about what we might do in the future. In particular, using dill (an extension to pickle) might be interesting, because we could store objects like functions which we can't currently.

excetara2
Thomas Kluyver
Collaborator
Thomas Kluyver
Collaborator

%store is now back in an extension for 0.12. To load it, do %load_ext storemagic. To have it always loaded, add 'storemagic' to the list c.InteractiveShellApp.extensions in your ipython_config.py file.

Thomas Kluyver takluyver closed this November 23, 2011
excetara2

Sorry!! For some reason it didn't work at first try for storing macros that were defined but restarted and now it's a go. THANKS FOR THE HARD WORK!!!!!!

Thomas Kluyver
Collaborator
excetara2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.