0

Can someone explain to me how such syntax works in python. From what I know, ret stores a boolean and img stores the next frame, but how is that facilitated. What other places can such functionality be utilized in Python?

ret, img = cap.read()
Zack Webster
  • 137
  • 1
  • 9
  • 1
    The function returns a tuple, and Python lets you unpack a tuple into individual components. – Dan Mašek Dec 30 '18 at 00:17
  • 1
    Returning several values in Python can be done by using a `tuple` (which contains at least 2 values). See [this answer](https://stackoverflow.com/a/9752970/3991125) for further details. For unpacking a tuple and multiple variable assignments have a look at [this blog post](https://treyhunner.com/2018/03/tuple-unpacking-improves-python-code-readability/). – albert Dec 30 '18 at 00:18

0 Answers0