I have some functions that can either work on a full mesh or on a set of components and I’m not sure how to handle the arguments for that. I see a couple options:
[ol]
[li]Mimic Maya’s argument looseness and accept either a mesh or a list of components as the first argument. It would determine which has been passed in and proceed accordingly.[/li][li]Have them as separate keyword arguments: mesh=None, components=None. Only one can be passed. The thing with this is that if I have a function that has positional arguments, then you end up passing the object(s) being operated on (mesh/components) after the positional arguments, which seems counterintuitive, like:[/li]
def exportWeights(outpath, mesh=None, components=None)
[li]Have the first argument be the mesh, and have a keyword argument to specify a subset of components to operate on, like:[/li]
def exportWeights(mesh, outpath, components=None)
If you prefer that method, what format would you expect the components to be in? A list of integer ids? A list of component strings (“pCube1.vtx[2:5]”, “pCube1.vtx[10]”)?
[/ol]
I’m tempted to use the first method since although it is not pythonic, it matches the behavior of other Maya functions that can work on a full mesh or a set of components.