Steven Lee Steven Lee - 11 months ago 79
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.