Printing variable name
How would I return a variable name in a function. E.g. If I have the function:
def mul(a,b):
return a*b
a = mul(1,2); a
b = mul(1,3); b
c = mul(1,4); c
This would return:
2
3
4
I would like it to return:
a = 2
b = 3
c = 4
How would I do this?
One answer could be:
(Sorry, but this is strictly speaking a valid answer.)
If something else is needed, something "more general", and this is certainly the case, than please describe this generality. Note also that the name of the variables "live" only in the "namespace of the code", it is not a good idea to let them live also "outside", as output... For testing purposes one may try something like...
(using this old fashioned string formatter, that may become soon obsolete, but it is the most simple one...)
(So what is the reason for such prints? Three prints as above can be understood also in the
form...)