[IPython-User] copy one cell from one notebook to another

Aaron Meurer asmeurer@gmail....
Tue Jan 15 04:26:25 CST 2013


I was thinking that this could be useful in some other ways too. I'm
supposing that you'll implement this as just copying the relevant part
of the notebook json file to the clipboard.  If you do it like this,
that opens up possibilities.  One could use this to do raw
modification of the json data in a relatively safe way.  Rather than
trying to edit the notebook file itself, which could be dangerous if
you mess up, you could just copy the cells you want to edit, paste it
into your text editor, do the modification, and repast them into the
notebook, which would assumedly do error checking first. Furthermore,
if you just use the raw format, someone could just copy the text
directly from the notebook and "paste" it into another (i.e., copy
with a text editor and paste with the notebook).

If you allow the ability to copy and paste several cells at once
(which you obviously should), this could also make things much more
efficient than any other method of moving cells from one notebook to
another, or merging two notebooks.

https://github.com/jonrohan/ZeroClipboard is what GitHub uses to
access the clipboard (according to
https://github.com/blog/1365-a-more-transparent-clipboard-button, the
only reliable way to do it is using Flash).  You could probably also
just use a poor-man's method, which would be to just give the user the
text and have him copy it manually, and visa-versa for paste.
Apparently even with Flash, the user must initiate the clipboard
access with a click.

Aaron Meurer

On Tue, Jan 15, 2013 at 2:30 AM, Matthias BUSSONNIER
<bussonniermatthias@gmail.com> wrote:
> Hi,
>
> To comments along the way.
>
> Cross Copy Past make sense in that cell also have metadata that could be
> copied along.
>
> There is a notebook flag to save py script each time you save a notebook so
> that you can 'import' your code.
>
> --
> Matthias
>
>
> Le 15 janv. 2013 à 08:34, Chao YUE a écrit :
>
> Thanks a lot for response. This feature might no be necessarily very useful.
> for me, the usage might be you have a "draft" notebook where you use
> interactive play.
> in this notebook you may have many cells but each cell only 1-2 lines. Then
> I use %save my_clean_code.py 20-40 (let's say I want 20-40 lines that are
> already clean
> and will be saved for future use.), then again with %loadpy my_clean_code.py
> I can load them
> again into a new cell. Now I would like to copy this cell to another clean
> notebook for storing the
> code (with better, clean visual feelings). Because I think notebook with its
> text and title features
> is actually a better tool to store code than files.
>
>  Chao
>
> On Tue, Jan 15, 2013 at 12:37 AM, Brian Granger <ellisonbg@gmail.com> wrote:
>>
>> This is something we have thought about doing, but we haven't gotten to it
>> yet.
>>
>> On Mon, Jan 14, 2013 at 3:35 PM, Paul Hobson <pmhobson@gmail.com> wrote:
>> > On Mon, Jan 14, 2013 at 2:00 PM, Chao YUE <chaoyuejoy@gmail.com> wrote:
>> >>
>> >> Dear all,
>> >>
>> >> Suppose I have notebook1 and notebook2, they are now listed in the same
>> >> notebook session.
>> >>
>> >> Could I copy one cell from notebook1 to notebook2?
>> >> by this way I can play in notebook1 but put all the tested codes neatly
>> >> in
>> >> notebook2.
>> >>
>> >> cheers,
>> >>
>> >> Chao
>> >
>> >
>> > Chao,
>> >
>> > I don't think I fully understand what behavior and perhaps
>> > (user-interface)
>> > feature you would like to see. I'm struggling to imagine a menu item or
>> > keyboard shortcut that would be simpler and faster than simply copying
>> > the
>> > text of an existing cell in notebook1 into a new cell in notebook2.
>> >
>> > If you need to copy over many cells at once, I would recommend simply
>> > copying the notebook ("Make a Copy" in the "File" menu).
>> > -paul
>> >
>> > _______________________________________________
>> > IPython-User mailing list
>> > IPython-User@scipy.org
>> > http://mail.scipy.org/mailman/listinfo/ipython-user
>> >
>>
>>
>>
>> --
>> Brian E. Granger
>> Cal Poly State University, San Luis Obispo
>> bgranger@calpoly.edu and ellisonbg@gmail.com
>> _______________________________________________
>> IPython-User mailing list
>> IPython-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
>
>
> --
> ***********************************************************************************
> Chao YUE
> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> UMR 1572 CEA-CNRS-UVSQ
> Batiment 712 - Pe 119
> 91191 GIF Sur YVETTE Cedex
> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
> ************************************************************************************
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>


More information about the IPython-User mailing list