2

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=False[, await_data=False[, partial=False[, manipulate=True[, read_preference=ReadPreference.PRIMARY[, exhaust=False[, compile_re=True[, **kwargs]]]]]]]]]]]]]]]]]])

Which seems ugly and confusing, yet appears in every api docs I've ever come across, I may lack some basic python knowledge.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
timfeirg
  • 1,426
  • 18
  • 37

2 Answers2

2

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.

subhacom
  • 868
  • 10
  • 24
0

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)
Abhijit
  • 62,056
  • 18
  • 131
  • 204