<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Great !</div><div><br></div>I think runipy already have such a feature, but I might have misunderstood :<div><br></div><div><br></div><div><blockquote type="cite">Passing Arguments<br><br>You can pass arguments to the notebook through environment variables. The use of environment variables is OS- and shell- dependent, but in a typical UNIX-like environment they can be passed on the command line before the program name:<br><br><div>$ myvar=value runipy MyNotebook.ipynb</div><br class="Apple-interchange-newline">Then in the notebook, to access myvar:<br><br><div>from os import environ</div><div>myvar = environ['myvar']</div><br class="Apple-interchange-newline">environ is just a dict, so you can use .get() to fall back on a default value:<br><br><div>from os import environ</div><div>myvar = environ.get('myvar', 'default!')</div></blockquote><div><br></div><div>from <a href="https://github.com/paulgb/runipy">https://github.com/paulgb/runipy</a></div><div><br></div><div><br></div><div>Maybe you can share part of the code.</div><div>-- </div><div>M</div><div><br></div><div><br></div><div><div>Le 8 oct. 2014 à 21:10, Thomas Kluyver a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div>Introducing another of my side projects: Nbparameterise<br><br><a href="https://github.com/takluyver/nbparameterise">https://github.com/takluyver/nbparameterise</a><br><br></div>The idea is that you prepare a notebook with some 'input' variable definitions in the first cell. These are standard assignments, like `a=200`, of (for now), strings, numbers and booleans. When you run nbparameterise, it will display a simple form where the user can supply new values for these variables. When the user clicks 'run notebook', their values are substituted in, the notebook is run and rendered to HTML.<br><br></div>To see a demo of this, clone the repository, run:<br><br></div>python3 -m nbparameterise Stock\ display.ipynb<br><br></div>and visit <a href="http://localhost:8888/">http://localhost:8888/</a> in your browser.<br><br></div>Notes:<br></div>- It builds an HTML form, but I've tried to abstract that from the core, so you could write a local GUI or a terminal interface for it quite easily.<br></div>- It's written in Python 3, but it will run notebooks in Python 2 if that's what the metadata indicates.<br></div>- We can integrate backends for other languages<br></div>- It's fairly rough - come and polish it.<br><br></div>We've heard from a couple of companies doing similar things privately; I hope this can form a common base.<br><br></div>Thomas<br><br>P.S. Suggestions for a better name welcome.<br></div>
_______________________________________________<br>IPython-dev mailing list<br><a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>http://mail.scipy.org/mailman/listinfo/ipython-dev<br></blockquote></div><br></div></body></html>