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

MinRK benjaminrk at gmail.com
Mon May 13 01:44:32 EDT 2013


%%overwrite doesn't sound good to me, since it isn't even accurate.
 %%fwrite (or the longer %%filewrite / %%writefile, which I understand but
would not prefer) would be the front runner for me.  Since all the magic
does is:

with open('filename', 'a' | 'w') as f:
    f.write(cell)

I don't think anything with `save` in the name would be less confusing than
plain `%%file`, since save already means something (a variety of things,
actually) totally unrelated.

I should point out that the current file magic, with PR #3313 cannot do
anything destructive without thoroughly explicit user action.

Personally, I think that restoring the overwrite prompt is all that should
be done, but I appreciate the motivation to come up with a new name.



On Sun, May 12, 2013 at 10:00 PM, Bradley M. Froehle <brad.froehle at gmail.com
> wrote:

> Hi,
>
> On Sun, May 12, 2013 at 4:46 PM, Fernando Perez <fperez.net at gmail.com>wrote:
>
>> On Sun, May 12, 2013 at 4:23 PM, Brian Granger <ellisonbg at gmail.com>
>> wrote:
>> > It feels like we are trying to create a mini file editor in a notebook
>> > cell.  %%file and friends are not supposed to be that in any way.  I
>> > think %%file with prompting the user for overwrite is sufficient for
>> > this particular purpose = write and store simple files in the
>> > notebook.
>>
>> No, nobody is trying to create an editor, it's just that the *name*
>> can be improved, and that's all I think is within scope here.  The
>> function makes a (potentially destructive) action, so it should be
>> named as a verb, much like %%load is.  %%file is indeed ambiguous, and
>> we have proven evidence of confusion, which we should take into
>> account.
>>
>
> I agree with Fernando that the best course of action here might be to
> rename `%%file` into something less ambiguous. If we go down that road, I
> agree that at a minimum the name should be a verb which indicates that it
> will write to a file.  Bonus points if it also indicates that the cell
> contents are what will be written to the file.
>
> The suggested verbs I've seen so far are `save`, `write`, and `overwrite`.
>  Each of these could then be decorated with `file` or `f` (or `cell`) to
> increase the specificity.  Unfortunately there isn't a good shell analogue
> to draw from here; the closest function would be `tee` which is very unix-y
> and not even perfect metaphor.
>
> Using `%%save` is problematic because there is already a different
> semantic meaning associated with `%save`.
>
> So, my vote would be for one of the following:
> * %%write
> * %%fwrite
> * %%writelines
> * %%writecell
>
> -Brad
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20130512/d0d14dd5/attachment.html>


More information about the IPython-dev mailing list