Skip to content

Instantly share code, notes, and snippets.

@yatakeke
Created November 27, 2019 01:05
Show Gist options
  • Save yatakeke/0881a7a16a1550b8437f7788c4e868ec to your computer and use it in GitHub Desktop.
Save yatakeke/0881a7a16a1550b8437f7788c4e868ec to your computer and use it in GitHub Desktop.
# linecache module allows one to get any line fromm python source code file
import linecache
linecache.getline(filename, line_number, module_globals=None)
# get line line_number from file named filename
# ex. line = linecache.getline('./test.txt', 8)
# get 8th line from test.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment