I want a function that can return the variable/object name as str like this :
def get_variable_name (input_variable): ## some codes >>get_variable
Perhaps you can use traceback.extract_stack() to get the call stack, then extract the variable name(s) from the entry?
def getVarName(a): stack = extract_stack() print(stack.pop(-2)[3]) bob = 5 getVarName(bob);
Output:
getVarName(bob)