ipython 5.1 export interactive session to script
<p>So, I know I can export an ipython session to a notebook, and then convert that notebook to many format using <code>jupyter nbconvert ...</code>. </p>

<p>However, the <a href="http://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=magic#magic-notebook" rel="nofollow">doc</a> also says I should be able to export the session directly to a python script if I give the filename a <code>.py</code> extension. That doesn't work, it still generates a notebook json file. </p>

<p>Can I get the desired behavior in some way?</p>

<p>Thanks.</p>

<p>The answer was, as Thomas K. said, use <code>%history -f ...</code> instead...</p>

python session ipython jupyter-notebook ipython-magic