Skip to content

Instantly share code, notes, and snippets.

@thebabush
Last active February 22, 2018 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebabush/c83bb61a1b656113da4cbd34df0fc6d7 to your computer and use it in GitHub Desktop.
Save thebabush/c83bb61a1b656113da4cbd34df0fc6d7 to your computer and use it in GitHub Desktop.
Run IPython.embed() inside Cython
# Cython/pyximport don't work 100% with the `inspect` module.
# For this reason, `IPython.embed()` is not able to get the locals from the current frame.
# This is how to work around that
import IPython
def embed(locs):
# Pass the locals explicitly
IPython.embed(user_ns=locs)
# Usage
embed(locals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment