### Navigation

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

# Module: `nbformat.current`

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

Authors:

- Brian Granger

## 2 Classes

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

  Bases: `exceptions.ValueError`

class `IPython.nbformat.current.``NotJSONError`

  Bases: `exceptions.ValueError`

## 10 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.``reads_json`(s, **kwargs)

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

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

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

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

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

`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.``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.``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.``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.

### Navigation

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