Ipython notes

From raju


disable exit confirmation

Add this to ~/.ipython/profile_default/ipython_config.py

    c.TerminalInteractiveShell.confirm_exit = False

If the file does not already exist, create it by running

    ipython profile create


copy paste code from ipython without ...

    %hist n


    %history n

Ref:- https://stackoverflow.com/questions/20858336/copy-code-from-ipython-without-leading-triple-dots

create default profile

    ipython profile create

Sample run

    $ ipython profile create
    [ProfileCreate] Generating default config file: '<HOME>\\.ipython\\profile_default\\ipython_config.py'
    [ProfileCreate] Generating default config file: '<HOME>\\.ipython\\profile_default\\ipython_kernel_config.py'

enter multiline statements in ipython

In git bash

  • ctrl-on - works in both IPython 5.3.0 and 7.3.0
  • ctrl-q + Enter - works in IPython 5.3.0 but not in 7.3.0

If that does not work, https://stackoverflow.com/questions/13536370/adding-line-breaks-in-ipython might help.

which package provides ipython in conda

The package name is ipython. Sample config file

    name: test_ipython
      - defaults
      - python=3.8.1
      # ipython is useful for debugging via REPL.
      - ipython=7.13.0



I am getting this exception with python 3.8.3, ipython 7.13.0, prompt_toolkit 3.0.5

notebook folder

tags | __file__

To get the directory in which the notebook is located

    current_folder = globals()['_dh'][0]

Code snippet to add it to the path

    import sys
    current_folder = globals()['_dh'][0]
    project_root = os.path.dirname(current_folder)
    if project_root not in sys.path: