I would like something doing the following:
s = "abc"
print (func(s))
Ouput:
s
I've seen it seems not possible to do so, but still I try if someone knows
I would like something doing the following:
s = "abc"
print (func(s))
Ouput:
s
I've seen it seems not possible to do so, but still I try if someone knows
from varname import nameof
s = 'abc'
print (nameof(s))
Output:
s
Package here:
https://github.com/pwwang/python-varname
Well, it is feasible, which does not mean it should be done. There is no difference with a print ("s") practically, plus there is dict if you want to associate a key and a value.
nameof(s) is any better than "s"...argname() in such a case. See my answer to this question. BTW, I am the author of the python-varname package.