pymel.util.iterateArgs

iterateArgs(*args, **kwargs)

Iterates through all arguments list: recursively replaces any iterable argument in *args by a tuple of its elements that will be inserted at its place in the returned arguments.

By default will return elements depth first, from root to leaves. Set postorder or breadth to control order.

Keywords :
depth : int

will specify the nested depth limit after which iterables are returned as they are

type

for type=’list’ will only expand lists, by default type=’all’ expands any iterable sequence

postorder : bool

will return elements depth first, from leaves to roots

breadth : bool

will return elements breadth first, roots, then first depth level, etc.

For a nested list represent trees:

a____b____c
|    |____d
e____f
|____g

preorder(default) :

>>> tuple(k for k in iterateArgs( 'a', ['b', ['c', 'd']], 'e', ['f', 'g'], limit=1 ))
('a', 'b', ['c', 'd'], 'e', 'f', 'g')
>>> tuple(k for k in iterateArgs( 'a', ['b', ['c', 'd']], 'e', ['f', 'g'] ))
('a', 'b', 'c', 'd', 'e', 'f', 'g')

postorder :

>>> tuple(k for k in iterateArgs( 'a', ['b', ['c', 'd']], 'e', ['f', 'g'], postorder=True, limit=1 ))
('b', ['c', 'd'], 'a', 'f', 'g', 'e')
>>> tuple(k for k in iterateArgs( 'a', ['b', ['c', 'd']], 'e', ['f', 'g'], postorder=True))
('c', 'd', 'b', 'a', 'f', 'g', 'e')

breadth :

>>> tuple(k for k in iterateArgs( 'a', ['b', ['c', 'd']], 'e', ['f', 'g'], limit=1, breadth=True))
('a', 'e', 'b', ['c', 'd'], 'f', 'g')
>>> tuple(k for k in iterateArgs( 'a', ['b', ['c', 'd']], 'e', ['f', 'g'], breadth=True))
('a', 'e', 'b', 'f', 'g', 'c', 'd')

Note that with default depth (-1 for unlimited) and order (preorder), if passed a pymel Tree result will be the equivalent of using a preorder iterator : iter(theTree)

Previous topic

pymel.util.isnan

Next topic

pymel.util.izip_longest

Core

Core Modules

Other Modules

This Page