Skip to content

Instantly share code, notes, and snippets.

@karolyi
Last active August 29, 2015 14:09
Show Gist options
  • Save karolyi/20fa77042dfa66023929 to your computer and use it in GitHub Desktop.
Save karolyi/20fa77042dfa66023929 to your computer and use it in GitHub Desktop.
Open interactive shell to investigate when something throws an exception
try:
# this is what fails here
context['children'] = mark_safe(u''.join(parts))
except:
import code
import readline
import rlcompleter
vars = globals()
vars.update(locals())
readline.set_completer(rlcompleter.Completer(vars).complete)
readline.parse_and_bind("tab: complete")
shell = code.InteractiveConsole(vars)
shell.interact()
# OR, w/ IPython:
from IPython import embed
embed() # this call anywhere in your program will start IPython
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment