How to pass a variable to magic ´run´ function in IPython

IPython expands variables with $name, bash-style. This is true for all magics, not just %run. So you would do: In [1]: filename = “myscript.py” In [2]: %run $filename [‘myscript.py’] myscript.py contains: import sys print(sys.argv) Via Python’s fancy string formatting, you can even put expressions inside {}: In [3]: args = [“arg1”, “arg2”] In [4]: %run … Read more

How to disable password request for a Jupyter notebook session?

The following is very unsafe, but you can remove the password completely with: jupyter notebook –ip=’*’ –NotebookApp.token=” –NotebookApp.password=” Without –NotebookApp.password=”, when connecting from a remote computer to a local Jupyter launched simply with: jupyter notebook –ip=’*’ it still asks for a password for security reasons, since users with access can run arbitrary Python code on … Read more

What are the differences between ipython and bpython?

If you just want an interactive interpreter, bpython should be fine. Just use it until you miss some feature you liked about IPython. There are lots of features that IPython offers over bpython: Special threading options. I like -gthread for experimenting with PyGTK and -pylab for matplotlib. direct invocation of shell commands. cd in IPython … Read more

How do I get the current IPython / Jupyter Notebook name

adding to previous answers, to get the notebook name run the following in a cell: %%javascript IPython.notebook.kernel.execute(‘nb_name = “‘ + IPython.notebook.notebook_name + ‘”‘) this gets you the file name in nb_name then to get the full path you may use the following in a separate cell: import os nb_full_path = os.path.join(os.getcwd(), nb_name)