Search code examples
pythonparametersdocumentnaming

In python socket library document, what does `bufsize[, flags]` mean?


According to Python library Socket documents function recvfrom has parameter bufsize[, flags]. In real example that use recvfrom, parameters are usally just one number that indicates bufsize. What does [, flags] mean?


Solution

  • In Python documentation the notation [, something] in a parameter list means that something is an optional parameter to the function.

    From that socket documentation link:

    See the Unix manual page recv(2) for the meaning of the optional argument flags; it defaults to zero.

    -- my emphasis on optional.

    So if you omit the flags argument it will be as though you'd called recvfrom(bufsize, 0)