Can you get the instance variable name from a class? [duplicate]
问题 This question already has answers here : Getting the name of a variable as a string (25 answers) Getting an instance name inside class __init__() [duplicate] (10 answers) Closed 5 years ago . I understand that you should never use variable names within the program, but I am using is strictly for debug purposes and would like to convey the name of the variable to the user for readability. I have a file like this: class MyClass(object): def __init__(self): pass def foo(msg=""): debug("Called