%save magic fails in clients without stdin if file already exists #1542

Closed
fperez opened this Issue Mar 31, 2012 · 6 comments

Comments

Projects
None yet
4 participants
Owner

fperez commented Mar 31, 2012

%save fails in the nb/qtconsole if a file already exists, because it tries to ask the user interactively and this produces a StdinNotImplementedError. We should in that case capture the exception, print instead a message and offer a -f option to support forced writes.

Owner

takluyver commented Mar 31, 2012

In some other case that tried to prompt the user, we went with printing a warning and overwriting the file, but I forget what that was.

Owner

fperez commented Mar 31, 2012

For something as serious as overwriting a whole .py file, I somehow
feel more comfortable requiring an explicit -f switch... What do you
think?

Owner

takluyver commented Mar 31, 2012

That makes sense, I just thought I'd note the contrast. Should we change %hist -f to behave the same way? We'd need to call the 'force' option something other than f if so, as that means file there. y for yes would be an obvious choice.

Also, we should get %save to use the ask_yes_no function - that's why we didn't spot it when we were doing the others.

Owner

ivanov commented Mar 31, 2012

for reference, the previous similar case Thomas mentions is %reset as it was described in #1268 and implemented in #1288

Owner

takluyver commented Mar 31, 2012

And at some point we've done the same for %hist -f, which is more similar to %save.

@minrk minrk referenced this issue Jun 13, 2012

Merged

add %save -f #1937

Owner

minrk commented Jun 13, 2012

See #1937

@minrk minrk closed this in 8d53f9a Jun 13, 2012

fperez added a commit to minrk/ipython that referenced this issue Jun 13, 2012

Merge pull request #1937 from minrk/save
Add -f (force) flag to %save, and display message about -f when ask_yes_no fails due to no stdin (Notebook).

closes #1542

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

add %save -f
adds force flag, and displays message about -f when ask_yes_no fails
due to no stdin (Notebook).

closes #1542

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

Merge pull request #1937 from minrk/save
Add -f (force) flag to %save, and display message about -f when ask_yes_no fails due to no stdin (Notebook).

closes #1542
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment