This is related to http://www.daniweb.com/software-development/python/threads/111526
However, in this case, I don't necessarily know the value of the var from which I am getting the name using vars(). Is there a way to get it?
prefix = 'char'
lidControls = []
lidControls2Make = ['uprLid', 'lwrLid','lwrLidTrack', 'uprLidTrack','uprLidRef','lidRig']
for control in lidControls2Make:
objTmp = prefix + '_'+control
cmds.spaceLocator(n=objTmp)
lidControls.append(objTmp)
# Assign the name to the control so we can access it by name later:
vars()[control] = objTmp
# So far, so good. The task is accomplished
# But how do I get the name of the variable created by vars()[control]?
# I want do this on each iteration of the loop:
varNameVal = dict(vars()[control]=objTmp) # This fails: "keyword can't be an expression"
print 'The value of ',varNameVal.keys()[0],'is now:',varNameVal.values()[0]\
#Result: The value of uprLid is now char_uprLid
Thanks much.