Repository: ipython/ipython

Issue:
%store magic not auto-restoring
I'm not sure when this started happening, I haven't used store in a while, but just ran into this. Basically, storing works, but restores don't automatically happen anymore. We should either:
1. changes this behavior so that the auto-restores start to happen again (preferred), or 
2. just update the docs to show how to make stored things available (via `store -r`). See this session

```
In [1]: pi = 3.1415926

In [2]: pi
Out[2]: 3.1415926

In [3]: store pi
Stored 'pi' (float)

In [4]: store
Stored variables and their in-db values:
pi                  -> 3.1415926

In [5]: 
Do you really want to exit ([y]/n)? y
15:44@~(HbIOTOH)$ ipython
In [1]: pi
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-68f7b1e53523> in <module>()
----> 1 pi

NameError: name 'pi' is not defined

In [2]: store
Stored variables and their in-db values:
pi                  -> 3.1415926

In [3]: store -r

In [4]: pi
Out[4]: 3.1415926
```

whereas the docs suggest one shouldn't need to do `store -r`:

```
Example::

  In [1]: l = ['hello',10,'world']
  In [2]: %store l
  In [3]: exit

  (IPython session is closed and started again...)

  ville@badger:~$ ipython
  In [1]: l
  Out[1]: ['hello', 10, 'world']
```



Discussion:
autorestore became configurable, and off by default. You can set `c.StoreMagic.autorestore = True` if you want it.

Yes, we should update the `%store` docstring.

I'm sure I just missed when it happened, but can you point me to the discussion on why the default was changed?  It's great that it's now configurable, but changing this default behavior from a long time ago was done for some particularly important reason, I presume?

`%store` was put in quarantine some time ago (probably before 0.11). I resurrected it as an extension (26afef67a14a361b7def5b5c4093dc8c4507babd), at which point you had to add the extension to config to get autorestore. Then in #1073 I made the extension load by default, and added the configuration for autorestore. So it's been a long time since autorestore was happening by default.

Ah, OK, thanks for refreshing my memory.  The question is then: should we make the default True again to match the old behavior, or do we update the docstring?

I'd vote for updating the docstring - I think autorestore is potentially
confusing if a user was just playing around with %store, and weeks later
notices that there's a mysterious 'a' variable appearing from nowhere. But
I don't feel strongly about this, and I can see the argument that %store
isn't much use without autorestore.


Resolving patch:
diff --git a/IPython/extensions/storemagic.py b/IPython/extensions/storemagic.py
--- a/IPython/extensions/storemagic.py
+++ b/IPython/extensions/storemagic.py
@@ -88,7 +88,10 @@ def store(self, parameter_s=''):
 
           ville@badger:~$ ipython
           In [1]: l
-          Out[1]: ['hello', 10, 'world']
+          NameError: name 'l' is not defined
+          In [2]: %store -r
+          In [3]: l
+          Out[3]: ['hello', 10, 'world']
 
         Usage:
 
@@ -98,7 +101,7 @@ def store(self, parameter_s=''):
                                 to disk
         * ``%store -d spam``  - Remove the variable and its value from storage
         * ``%store -z``       - Remove all variables from storage
-        * ``%store -r``       - Refresh all variables from store (delete
+        * ``%store -r``       - Refresh all variables from store (overwrite
                                 current vals)
         * ``%store -r spam bar`` - Refresh specified variables from store
                                    (delete current val)


Test patch: