Little help with maya commands & python

I’ve only got a couple things to say.
First, THANK YOU for using the whole word for the keyword arguments! Please don’t ever stop.

It may be more convenient in the future to not have to unpack all those values when finding the distance between 2 points. So instead of def distance(x1, x2, y1, y2, z1, z2):
I would do something like def distance(point1, point2):. However, this is not needed at all, and is just my own personal preference.

Oh, and you shouldn’t ever use a mutable object as a default. You’ve got
def removeDuplicate(maxDistance = 0.1, allObjectsList = []):
It should be allObjectsList=None in the function definition
And then check if allObjectsList is None: allObjectsList = [] later in the function
The reason is changing that argument actually changes the default.

def myAppender(myVal, myArg=[]):
    myArg.append(myVal)
    return myArg

print myAppender('T') # prints ['T']
print myAppender('A') # prints ['T', 'A']
print myAppender('O') # prints ['T', 'A', 'O']

As for the progress bar, I don’t know my way around maya UI commands, sorry.
But other than that, LGTM.


As a small aside, does anybody know why we use import maya.cmds as cmds instead of from maya import cmds?

1 Like