One of the most underused aspects of python is the documentation system. In any def, one can add a line or two of text documenting what the function does, or how to use it. The string needs to be encapsulated by three quotes (single or double) on each side. '''Like this''' or """like this""".
Here is a simple Maya function that gets the parent of the passed object. Note the documentation tag.
def getParent():
'''This def returns the parent of the passed object'''
selObject = cmds.ls(sl=True)
par = cmds.listRelatives(p=True)
return par
myPar = getParent()
print myPar[0]
Now, for the fun part, you can use something like this to find out what is going on with the def. print getParent.__doc__
You can even store the documentation into a variable as you would any string. helpDoc = getParent.__doc__.
Commenting your code:Brilliant. Documenting your code:Priceless
