Skip to content

Documentation shows misleading Python syntax #19896

@james10424

Description

@james10424
System information (version)
  • OpenCV => 4.5.2-dev
  • Operating System / Platform => None
  • Compiler => None
Detailed description

https://docs.opencv.org/master/d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563
The documentation above (and in general) shows misleading Python syntax, namely:
None = cv.imshow(winname, mat)
This suggests that we can assign None to the return value of cv.imshow(winname, mat).
This suggestion is infered from the above one: retval = cv.getWindowProperty(winname, prop_id), because retval is not a type, and this is a valid Python syntax, one would assume that this exact code could be run with Python.
However, we know that None cannot be assigned, so None = cv.imshow(winname, mat) makes no sense and is syntatically wrong.
So one might assume that the value before = indicates the return value of the function on the right (which should totally follow PEP3107), since None is a value, but retval is not a type nor any predefined constant. Therefore, this documentation gives conflicted interpretations.

Steps to reproduce

Visit https://docs.opencv.org/master/d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions