You’ll need to use locals() which is a built-in dictionary of all previously declared variables.
curve1="curve2" curve2="curve4" curve3="curve6" print locals()['curve1'] == "curve2" # Prints True locals() documentation <https://docs.python.org/2/library/functions.html#locals> Though as enrac5 says, you are probably better off using a look-up table (i.e. a dictionary). curves = {'curve1': 'curve2', 'curve2': 'curve4', 'curve3': 'curve6'}print curves['curve1'] == 'curve2' # Prints true On 27 October 2014 12:39, sam williams <[email protected]> wrote: > Hi there!, > > say i have 10 curves in my maya scene. "curve1", "curve2", "curve3" and > on....., and i have a variables curve1, curve2, curve3 which will be > storing specific curves in the scene > > i was wondering is there a way of calling the variable curve1 curve2 and > curv3 in a loop by constructing two strings to create the variable, like > this: > > num=1 > > curve1="curve2" > curve2="curve4" > curve3="curve6" > > while num<=3: > > currentCurve="curve" + str(num) > > print currentCurve > > num+=1 > > now this doesnt work, it prints curve1, curve2, curve3. - where i need it > to print curve2, curve4, curve6 > > you see what i mean kind of?. > so its just about calling a variable, but first construcing the variable > name with two strings. is this at all possible in python?? > > thanks alot, > Sam > > > > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/7605cfcc-c471-4657-9e92-a3a0b31686b3%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/7605cfcc-c471-4657-9e92-a3a0b31686b3%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- *Marcus Ottosson* [email protected] -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCHgdXFWZHZy7HYVqq5rt3TSN0311VyuEh7DQUVL0CPFQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
