Steven Lee Steven Lee - 1 year ago 127
Python Question

Python asterisk before function

I am following this tutorial:

and in one of the lines there is the function:

(cnts, boundingBoxes) = zip(*sorted(zip(cnts, boundingBoxes),
key=lambda b:b[1][i], reverse=reverse))

I want to know what is the use of the asterisk before the
function call.

Answer Source

You need to understand what the code is trying to do. The first part sorted(zip(cnts, boundingBoxes) creates a sorted list which is the zipped version of contours and boundingBoxes. The asterisk "unzips" it so that the outer zip can produce the correct output.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download