[IPython-dev] Create New Notebook from Command-line

Andrew Gibiansky andrew.gibiansky at gmail.com
Fri Dec 5 14:25:10 EST 2014


Matthias,

That's perfect and exactly the sort of thing I was looking for. I looked
around the IPython API but didn't quite get to the code snippet you showed.

Thanks!

On Fri, Dec 5, 2014 at 11:06 AM, Wes Turner <wes.turner at gmail.com> wrote:

>
>
> On Fri, Dec 5, 2014 at 2:57 AM, Matthias BUSSONNIER <
> bussonniermatthias at gmail.com> wrote:
>
>> Hi Andrew.
>>
>> Base on a Fernando example would the following python snippet suit you ?
>>
>> import IPython.nbformat as nbf
>> nb = nbf.v4.new_notebook()
>> text = "This is an auto-generated notebook"
>> nb['cells'] = [ nbf.v4.new_markdown_cell(text)]
>> nb['cells'].append(nbf.v4.new_code_cell('#'+text))
>> fname = 'test.ipynb'
>>
>> with open(fname, 'w') as f:
>>     nbf.write(nb, f, 4)
>
>
> 1. This could be a useful commandline option.
>
> 2. You could accomplish the same with a
> https://github.com/audreyr/cookiecutter jinja2 project template.
>
>     * There could be variations on such a template e.g. with default
> headings for:
>       *
> https://en.wikipedia.org/wiki/Scientific_method#Elements_of_the_scientific_method
>       * { Abstract, Question, Hypothesis, Experiment, Observations/Data,
> Analysis, Conclusion, ... }
>
> _______________________________________________
> 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/20141205/1a0c9a53/attachment.html>


More information about the IPython-dev mailing list