Skip to content

Instantly share code, notes, and snippets.

@clowwindy
Created August 3, 2012 07:46
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 clowwindy/3245499 to your computer and use it in GitHub Desktop.
Save clowwindy/3245499 to your computer and use it in GitHub Desktop.
print current frame
#!/usr/bin/python
import inspect
LINES_TO_PRINT = 5
# blahblahblah
# foobar
frame = inspect.currentframe()
with open(frame.f_code.co_filename, 'rb') as f:
print ''.join(f.readlines()[frame.f_lineno - LINES_TO_PRINT:frame.f_lineno])
# blahblahblah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment