[Maya PyMel] Proper syntax for getting series of attribute values

Hi all,

I want to print out the values for a list of attributes on every transform selected using methods from the Transform class, but I think I’m messing up the syntax.

My simple script:

from pymel.core import *

object = ls(sl=1)
channels = [".translateX",".translateY"]

type(object[0])
print (object[0].translateX.get() ) # this works
getAttr(object[0] + channels[0])  # this also works

print ((object[0] + channels[0]).get() ) # this doesn't work
print ((object[0] + channels[0]) + '.get()' ) # this doesn't work

Can anyone point me in the right direction? Maybe it’s not possible?

Thanks for reading!

attrs = ['tx', 'ty']
for obj in pm.ls(sl=True):
    for attr in attrs:
        print attr, obj.attr(attr).get()

Which is (in most cases) the same method that is being used internally when you call object[0].translateX.

[QUOTE=capper;20899]

attrs = ['tx', 'ty']
for obj in pm.ls(sl=True):
    for attr in attrs:
        print attr, obj.attr(attr).get()

Which is (in most cases) the same method that is being used internally when you call object[0].translateX.[/QUOTE]

Thanks so much for the quick reply, capper!