### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# nbformat.current

## Module: `nbformat.current`

Inheritance diagram for `IPython.nbformat.current`:

The official API for working with notebooks in the current format version.

Authors:

- Brian Granger

## Class

## `NBFormatError`

class `IPython.nbformat.current.``NBFormatError`

  Bases: `exceptions.Exception`

  `__init__`()

    x.__init__(...) initializes x; see help(type(x)) for signature

  `args`
  `message`

## Functions

`IPython.nbformat.current.``parse_json`(s, **kwargs)

  Parse a string into a (nbformat, dict) tuple.

`IPython.nbformat.current.``parse_py`(s, **kwargs)

  Parse a string into a (nbformat, string) tuple.

`IPython.nbformat.current.``parse_xml`(s, **kwargs)

  Parse a string into a (nbformat, etree) tuple.

`IPython.nbformat.current.``read`(fp, format, **kwargs)

  Read a notebook from a file and return the NotebookNode object.

  This function properly handles notebooks of any version. The notebook returned will always be in the current version’s format.

  Parameters :

  fp : file

  > Any file-like object with a read method.

  format : (u’json’, u’ipynb’, u’py’)

  > The format that the string is in.

  Returns :

  nb : NotebookNode

  > The notebook that was read.

`IPython.nbformat.current.``reads`(s, format, **kwargs)

  Read a notebook from a string and return the NotebookNode object.

  This function properly handles notebooks of any version. The notebook returned will always be in the current version’s format.

  Parameters :

  s : unicode

  > The raw unicode string to read the notebook from.

  format : (u’json’, u’ipynb’, u’py’)

  > The format that the string is in.

  Returns :

  nb : NotebookNode

  > The notebook that was read.

`IPython.nbformat.current.``reads_json`(s, **kwargs)

  Read a JSON notebook from a string and return the NotebookNode object.

`IPython.nbformat.current.``reads_py`(s, **kwargs)

  Read a .py notebook from a string and return the NotebookNode object.

`IPython.nbformat.current.``reads_xml`(s, **kwargs)

  Read an XML notebook from a string and return the NotebookNode object.

`IPython.nbformat.current.``write`(nb, fp, format, **kwargs)

  Write a notebook to a file in a given format in the current nbformat version.

  This function always writes the notebook in the current nbformat version.

  Parameters :

  nb : NotebookNode

  > The notebook to write.

  fp : file

  > Any file-like object with a write method.

  format : (u’json’, u’ipynb’, u’py’)

  > The format to write the notebook in.

  Returns :

  s : unicode

  > The notebook string.

`IPython.nbformat.current.``writes`(nb, format, **kwargs)

  Write a notebook to a string in a given format in the current nbformat version.

  This function always writes the notebook in the current nbformat version.

  Parameters :

  nb : NotebookNode

  > The notebook to write.

  format : (u’json’, u’ipynb’, u’py’)

  > The format to write the notebook in.

  Returns :

  s : unicode

  > The notebook string.

`IPython.nbformat.current.``writes_json`(nb, **kwargs)

`IPython.nbformat.current.``writes_py`(nb, **kwargs)

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »