[IPython-dev] what goes wrong with %%file
W. Trevor King
wking at tremily.us
Sun May 12 10:51:39 EDT 2013
On Sun, May 12, 2013 at 07:36:27AM -0700, Min RK wrote:
> 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.
> [snip]
> > 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.
Ah, thanks. I didn't see anything load-related in the cell magics
list [1], and I couldn't even find a standard-magic list in the docs
:p [2]. I wasn't proposing an editor-like command, I was saying that
the ambiguity Greg points out with `%%file` is understandable. In the
“explicit is better than implicit” spirit, it would make sense to use
a more explicit name for a file-saving magic. On the other hand,
backwards compatibility has a good deal of weight too.
Cheers,
Trevor
[1]: http://ipython.org/ipython-doc/dev/whatsnew/version0.13.html#cell-magics
[2]: I suppose auto-completion makes such a listing less important.
--
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130512/09061ced/attachment.sig>
More information about the IPython-dev
mailing list