What value to use for execution_count in code cells of iPython notebooks?
Question: What is the best value to use as an input argument for `execution_count` when
generating an iPython notebook as a json file?

I understand it should be set to `null` but a json dump automatically puts
quotes around it so I perform a search-replace after creation and remove
these. However ipython notebook still isn't happy with it. I'm on Python 2.7,
iPython notebook 4.0.5.

    
    
    import json, fileinput, re
    
    # Create the cell of python code
    code_cell = {
        "cell_type": "code",
        "execution count": "null",
        "metadata": {
            "collapsed": False,
            "autoscroll": False,
        },
        "source": ["import os\n", "import numpy as np"],
        "outputs": [],
    }
    
    # Create ipython notebook dictionary
    nbdict = { 'metadata': {}, \
        'nbformat': 4,
        'nbformat_minor': 0,
        'cells': [code_cell]
        }
    
    with open("test.ipynb", 'w') as outfile:
        json.dump(nbdict, outfile)
    
    # Strip double quotes from execution_count argument.  
    
    file = fileinput.FileInput("test.ipynb", inplace=True)
    for line in file:
        print(re.sub(r'"null"', 'null', line))
    file.close()
    

The error I receive is `Notebook Validation failed: Additional properties are
not allowed (u'execution count' was unexpected):`

This is even after I have `"execution count": null,` in the json file.


Answer: Looks like you are missing an underscore: `"execution count"` should be
`"execution_count"`, and then the `null` should work fine.

