Let's say I have:
a = (1,2,3,4,5)
b = (2,4,5,6,7)
c = (a,b)
where a, b and c are tuples. How do I get the name of 'a' and 'b'? I was trying with:
for x in c:
    print(type(x).__name__)
but it gives me tuple
Let's say I have:
a = (1,2,3,4,5)
b = (2,4,5,6,7)
c = (a,b)
where a, b and c are tuples. How do I get the name of 'a' and 'b'? I was trying with:
for x in c:
    print(type(x).__name__)
but it gives me tuple
 
    
    The python-varname package allows you to inspect variable names in general. Maybe that will help you. You can get it with pip install varname. Its GitHub is here and the README there provides usage examples.
edit: actually, for your use case, the comment given by @chepner is spot-on. I'll leave this answer up in case the package is of use to someone trying to get a variable name for a different case, since it would work on for example a and b themselves. But @chepner explains exactly why getting 'a' and 'b' out of 'c' is not going to be possible.
