This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: nbformat.v3

The main API for the v3 notebook format.

1 Class

class IPython.nbformat.v3.NotebookNode(*args, **kw)

Bases: IPython.utils.ipstruct.Struct

11 Functions


Convert a v3 notebook to v2.


nb : NotebookNode

The Python representation of the notebook to convert.

IPython.nbformat.v3.new_author(name=None, email=None, affiliation=None, url=None)

Create a new author.

IPython.nbformat.v3.new_code_cell(input=None, prompt_number=None, outputs=None, language='python', collapsed=False, metadata=None)

Create a new code cell with input and output

IPython.nbformat.v3.new_heading_cell(source=None, level=1, rendered=None, metadata=None)

Create a new section cell with a given integer level.

IPython.nbformat.v3.new_metadata(name=None, authors=None, license=None, created=None, modified=None, gistid=None)

Create a new metadata node.

IPython.nbformat.v3.new_notebook(name=None, metadata=None, worksheets=None)

Create a notebook by name, id and a list of worksheets.

IPython.nbformat.v3.new_output(output_type, output_text=None, output_png=None, output_html=None, output_svg=None, output_latex=None, output_json=None, output_javascript=None, output_jpeg=None, prompt_number=None, ename=None, evalue=None, traceback=None, stream=None, metadata=None)

Create a new output, to go in the cell.outputs list of a code cell.

IPython.nbformat.v3.new_text_cell(cell_type, source=None, rendered=None, metadata=None)

Create a new text cell.

IPython.nbformat.v3.new_worksheet(name=None, cells=None, metadata=None)

Create a worksheet by name with with a list of cells.


Parse a notebook filename.

This function takes a notebook filename and returns the notebook format (json/py) and the notebook name. This logic can be summarized as follows:

  • notebook.ipynb -> (notebook.ipynb, notebook, json)
  • notebook.json -> (notebook.json, notebook, json)
  • notebook.py -> (notebook.py, notebook, py)
  • notebook -> (notebook.ipynb, notebook, json)

fname : unicode

The notebook filename. The filename can use a specific filename extention (.ipynb, .json, .py) or none, in which case .ipynb will be assumed.


(fname, name, format) : (unicode, unicode, unicode)

The filename, notebook name and format.

IPython.nbformat.v3.upgrade(nb, from_version=2, from_minor=0)

Convert a notebook to v3.


nb : NotebookNode

The Python representation of the notebook to convert.

from_version : int

The original version of the notebook to convert.

from_minor : int

The original minor version of the notebook to convert (only relevant for v >= 3).