Skip to content

Instantly share code, notes, and snippets.

@emilisto
Created August 16, 2013 11:10
Show Gist options
  • Save emilisto/6249037 to your computer and use it in GitHub Desktop.
Save emilisto/6249037 to your computer and use it in GitHub Desktop.
A little tool I came up with to be able to quickly work with API's I'm unfamiliar with. Just call `inspect()` anywhere in the code and you'll get an interactive prompt where you can interact with all variables, see their attributes, methods etc.
import bpython
import inspect
def interact():
"""
Just run interace() anywhere in your code, and you'll get a sweet
interactive bpython interpreter with access to the scope of where you
called it. Great for investigating new API's.
"""
try:
stack = inspect.stack()
scope = stack[1][0]
vars = scope.f_globals.copy()
vars.update(scope.f_locals)
finally:
del stack
bpython.embed(locals_=vars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment