I have trouble with understanding the role of the underscore in last line of below code. I've read that functions of _ consists of storing last expression, but can be used as well to omit certain values. I don't now why it is used here. Thank You in advance for help
I found this thread, which was helpful with understanding of functions which _ can fulfill, but I still don't know in which way it was used in this code: What is the purpose of the single underscore "_" variable in Python?
@staticmethod
def frames():
camera = cv2.VideoCapture(Camera.video_source)
if not camera.isOpened():
raise RuntimeError('Could not start camera.')
while True:
# read current frame
_, img = camera.read() #Obtain images captured by the camera
Read more here: https://stackoverflow.com/questions/67011573/what-is-the-role-of-underscore-in-assigning-variable-process-python
Content Attribution
This content was originally published by Paweł Magdański at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.