Skip to content Skip to sidebar Skip to footer

In Any Python Api Documentation, Why Are Optional Arguments Written In A Nested Style?

It's just, why do this: find([spec=None[, fields=None[, skip=0[, limit=0[, timeout=True[, snapshot=False[, tailable=False[, sort=None[, max_scan=None[, as_class=None[, slave_okay=F

Solution 1:

This is a convention borrowed from extended Backus-Naur form. As pointed out above by Abhijit, the nesting means optional to the optional argument etc.

Solution 2:

I do not have any authentic source to back my statement

Optional positional arguments presented in a nested style would enforce the proper ordering of the fields.

For Example in os module for fdopen

os.fdopen(fd[, mode[, bufsize]])

Indicates that mode and bufsize are optional but if you are specifying bufsize you should also specify mode.

For Keywords argument, on the other hand, a default value is specified without any order enforcement to inndicate that the value is optional in which case, the parameter would be initialized with the default value

For example in [re] module for split

split(string, maxsplit=0)

Post a Comment for "In Any Python Api Documentation, Why Are Optional Arguments Written In A Nested Style?"