Le mardi 1 mai 2018 13:17:02 UTC+2, John Cremona a écrit :
>
> I was using the jupyter notebook's magic %%writefile, where
> you put "%%writefile [-a] filename.py" at the top of a cell and
> then evaluating the cell writes the cell's contents to the file
> (overwriting by default, or appending if you give the -a flag).
>
> I found that the file so written to has the correct contents except
> that there is no final newline character.  This is particularly
> annoying when you try (as I did) writing the contents of several
> cells to the same file, using -a on all but the first, since after
> doing all that, you then have to edit the file to insert some newlines.
>
> Putting a blank line at the bottom of the cell makes no difference,
> as it is ignored.  Putting a comment character # on the last line
> is no better since that gets prepended to the first line of the next
> cell whose contents is appended.
>
> This is not Sage-specific since the same happens if I run
> jupyter-notebook from the command line (on ubuntu linux)
> and create a new python3 notebook. 
>
> I found this post
> 
https://stackoverflow.com/questions/36520723/how-to-append-a-file-with-a-newline-using-writefile-a-command-in-jupyter
> which suggests putting a blank line at the top of each appended cell,
> and that does work (though the resulting file still has no final newline).
>
> This seems rather counter-intuitive to me!

Probably best asked on the Project Jupyter mailing list: 
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to