Trivial example:
a = 1
b = 2
c = 3
rrr = []
rrr.append(a)
rrr.append(b)
rrr.append(c)
rrr
returns:
[1,2,3]
But I need to get:
[a,b,c]
I've seen this:
How can I get the name of an object in Python?
But I'm not quite sure if the solution is saying only functions have a __name__
attribute.
The problem I'm trying to solve is I have a class, and one of its attributes is a list of other attributes it has, so I can iterate through them easily (they all go together very frequently and they're all booleans). But I need to do a check against that list that grabs its name, not its value.
Shouldn't the list point to the variable first and then the value that the variable is referencing, or does python in this instance just skip the little post-it notes that are the variables and just look at the actual objects?
If so, is there anyway to force it, during the construction of the list, to go the long route and look at the post-it note variables so I can recover them?