[IPython-dev] what goes wrong with %%file

Min RK benjaminrk at gmail.com
Sun May 12 10:36:27 EDT 2013



On May 12, 2013, at 7:23, "W. Trevor King" <wking at tremily.us> wrote:

> On Sun, May 12, 2013 at 09:56:57AM -0400, Greg Wilson wrote:
>> If I have a file called 'data.txt' on my hard drive, and put:
>> 
>> %%file data.txt
>> 
>> in a cell and then execute it, 'data.txt' is overwritten and the data is 
>> lost.  Everyone (including me, when I'm forgetful) expects this to load 
>> and display the existing file content if the file exists, just like an 
>> editor would.

it should probably at least give up and provide a helpful message when the cell is empty, rather than writing an empty file.

> 
> Maybe the current %%file magic should be renamed to %%save-file, and
> you're expecting a (currently unimplemented?) %%open-file.

it is *not* an editor - if you want to load a file's contents into a cell, that's precisely what %load does.

>  I don't
> like the idea of mandatory interactivity.  It looks like there was
> previous work in this direction (234309d, ask_yes_no on %%file
> overwrite, 2012-06-05), but it was dropped in d0c569e (%%file always
> overwrites, 2012-06-09).  The commit message doesn't elaborate on the
> motivation for dropping the interactivity.

The interactivity was dropped because the notebook didn't support any interaction. This is no longer true, so going back to prompting for overwrite probably makes sense.

> 
> Cheers,
> Trevor
> 
> -- 
> This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
> For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev



More information about the IPython-dev mailing list