This thread discusses how to get the name of a function as a string in Python: How to get a function name as a string?
How can I do the same for a variable? As oppose
With Python 3.8 one can simply use f-string debugging feature:
>>> foo = dict() >>> f'{foo=}'.split('=')[0] 'foo'