Here's what works for me to get the line number in Python 3.7.3 in VSCode 1.39.2 (dmsg
is my mnemonic for debug message):
import inspect
def dmsg(text_s):
print (str(inspect.currentframe().f_back.f_lineno) + '| ' + text_s)
To call showing a variable name_s
and its value:
name_s = put_code_here
dmsg('name_s: ' + name_s)
Output looks like this:
37| name_s: value_of_variable_at_line_37