pythonipythonhistory

how can I avoid storing a command in ipython history?


In bash I can prevent a command from being saved to bash history by putting a space in front of it. I cannot use this method in ipython. How would I do the equivalent in ipython?


Solution

  • Obsolescence note: this was written for IPython 4.0.1. As of v5, IPython no longer uses readline.


    No stock way, can be added in or worked around.

    There are two kinds of history in IPython:

    There are two ways to solve the problem for either layer:

    Alternatively, if you only require this to enter passwords, consider other ways that don't echo the password on screen (thus not making it a part of console history):