[IPython-dev] what goes wrong with %%file
Greg Wilson
gvwilson at third-bit.com
Sun May 12 09:56:57 EDT 2013
We just ran six Software Carpentry boot camps in a five-day period, and
things largely went well --- most of our instructors are now using the
IPython Notebook for all Python instruction, and learners are responding
well. One problem that did come up, though, is the behavior of
'%%file'. 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. I realize that it's problematic to have the in-cell
display update automagically if and when the file is edited by some
other tool, but "load if exists, create if not" seems like it ought to
be straightforward. Failing that, a prompt that says, "This exists, are
you sure you want to overwrite it?" would be better than what happens now.
Thoughts?
Thanks,
Greg
More information about the IPython-dev
mailing list