0

Hello I'm new to python and I'm trying to learn OpenCV. When I check the API references for OpenCV I came across this types of parameter description.

cv2.imread(filepath[, flags])

What does the "[, flags]" part mean? I know it takes in two variable, which is filepath and flags, but I don't know the meaning of the square bracket. Any help is appreciated!

Miki
  • 40,887
  • 13
  • 123
  • 202
Steven97102
  • 334
  • 5
  • 17
  • Second parameter is optional. – Robby Cornelissen Mar 15 '19 at 05:11
  • So is it the same as **kwargs or *kwargs ? But why is the left square bracket on the left of the comma anyway? – Steven97102 Mar 15 '19 at 05:14
  • 1
    Because if you don't provide the second argument, you don't have to type the comma either? – Robby Cornelissen Mar 15 '19 at 05:17
  • 1
    @Steven97102 To be clear it's only a documentation thing, not code. You might also encounter functions expecting a parameter to have a specific value, in that case the choices you have can be written like this `a|b|c`. – Guimoute Mar 15 '19 at 09:05
  • This is common notation in documentation for many programming languages. See [here](https://stackoverflow.com/questions/10925478/how-to-read-api-documentation-for-newbs) – trincot Mar 15 '19 at 09:06

0 Answers0