2012
07.05

What’s the smart way to pick any arbitrary number of items with XSI’s PickElement or PickObject commands? Read below… 😀

How or why does this work? What the heck is yield doing?

In Python, you can think of a “yield” statement like a “return” one, except it doesn’t finish the function evaluation.

A function using yield will act as a “generator“, returning one thing at a time each time it is called, until it stops yielding. (In our snippet, returning one tuple containing three pieces of data.) When iterating/looping in Python, when nothing is returned it stops, therefore when a yielding function stops returning, the loop ends.

Hat tip to Xavier Lapointe for originally showing me the trick and to Patrick Boucher for helping me remember the yield logic.

No Comment.

Add Your Comment