I am following this tutorial:
http://www.pyimagesearch.com/2015/04/20/sorting-contours-using-python-and-opencv/#comment-405768
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 sorted function call.
Asterisk is unpacking operator:
>>> list(range(3, 6)) # normal call with separate arguments
[3, 4, 5]
>>> args = [3, 6]
>>> list(range(*args)) # call with arguments unpacked from a list
[3, 4, 5]
More about unpacking operator:
https://docs.python.org/3/tutorial/controlflow.html#unpacking-argument-lists
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With