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 in Python?
How can I do the same for a variable? (note that Python variables do not have the attribute
foo = dict()
foo['bar'] = 2
# List of dictionaries for my DataFrame
list_of_dicts = [n_jobs, users, queues, priorities]
The only objects in Python that have canonical names are modules, functions, and classes, and of course there is no guarantee that this canonical name has any meaning in any namespace after the function or class has been defined or the module imported. These names can also be modified after the objects are created so they may not always be particularly trustworthy.
What you want to do is not possible without recursively walking the tree of named objects; a name is a one-way reference to an object. A common or garden-variety Python object contains no references to its names. Imagine if every integer, every dict, every list, every Boolean needed to maintain a list of strings that represented names that referred to it! It would be an implementation nightmare, with little benefit to the programmer.