Created
February 26, 2015 20:41
-
-
Save whoiscarlo/6afd4ca4be66db4a1364 to your computer and use it in GitHub Desktop.
Fucntion to grab the current line number python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This provides a lineno() function to make it easy to grab the line | |
number that we're on. | |
Danny Yoo ([email protected]) | |
""" | |
import inspect | |
def lineno(): | |
"""Returns the current line number in our program.""" | |
return inspect.currentframe().f_back.f_lineno | |
if __name__ == '__main__': | |
print "hello, this is line number", lineno() | |
print "and this is line", lineno() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment