Now, I do not know pymel or anything related to Maya, but if object.translateX.set(1.5)
works, then I think the access works like normal object attribute access, so you can get an attribute by name using the getattr(object, attrname[, default_value])
.
BTW range(0, 5, 1)
is the same as range(5)
; and means a list [ 0, 1, 2, 3, 4 ]; your list has 6 elements so you'd need range(6)
to iterate over it - but as for loop can iterate over any iterable, you should just iterate over your attribute names. Thus:
attributes = ['translateX', 'translateY', 'translateZ',
'rotateX', 'rotateY', 'rotateZ']
for a in attributes:
getattr(object, a).set(1.5)
should do what you wanted.
Update: pymel seems to also support .attr()
for objects, thus
for a in attributes:
object.attr(a).set(1.5)