I am trying to create a logger function:
def logger(someVariable):
# some code that prints the name of someVariable
So when I call the function:
logger(myvarA) # should output the string 'myvarA'
logger(someobj.varB) # should output the string 'someobj.varB'
logger(myarr[3]) # should (probably) output 'myarr[3]'
Not sure if all or even any of these cases are possible? The use case for this is to have a simple function in iPython Notebook to log any variables for their values without having to type something like below:
logger(myVarA,'myVarA')
logger(myarr[i],'myarr[{}]'.format(i))