<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 3 November 2013 01:17, Raniere Silva <span dir="ltr"><<a href="mailto:ra092767@ime.unicamp.br" target="_blank">ra092767@ime.unicamp.br</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id=":15s" style="overflow:hidden">I need to convert some Python2 `print` statements to Python3 `print` function<br>


in .ipynb files. `2to3` didn't work. What tool I can use?</div></blockquote></div><br><br></div><div class="gmail_extra">Copying my comment from the Software Carpentry Github thread here: <a href="https://github.com/swcarpentry/bc/issues/107">https://github.com/swcarpentry/bc/issues/107</a><br>

<br>We don't have an automated conversion tool for notebooks ourselves - 
we don't curate enough notebooks ourselves to really need one. However, 
it should be feasible to write something that loads a notebook, runs 
2to3 on each of the code cells, and saves it again. I'm happy to help 
build that. It's not entirely trivial, though:

<ul><li>Some changes should only be done once per notebook, e.g. adding <code>from __future__</code> imports.</li><li>IPython special syntax, e.g. <code>%magics</code> might break the parser 2to3 is using.</li></ul><p>Thanks,</p>

<p>Thomas<br></p><br></div></div>