Last active
January 24, 2026 14:04
-
-
Save ram1123/fd650fcab3f5d04aceb8fc6436ae888f to your computer and use it in GitHub Desktop.
Get current line number in print statement using python program
This file contains hidden or 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
| import os | |
| from inspect import currentframe | |
| def get_linenumber(): | |
| cf = currentframe() | |
| return cf.f_back.f_lineno | |
| print("Current Line number: {}".format(get_linenumber())) | |
| print("Current File name : {}".format(os.path.basename(__file__))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment