3

what is the difference between these,

max(iterable, *[, key, default])
max(arg1, arg2, *args[, key])
iter(object[, sentinel])
input([prompt])

plus is there a documentation for more variations to these? from what I understand,

[, sentinel] means sentinel is optional, maybe prompt is also optional

if i need to define multiple optional arguments then I use * like *[, key, default]

and for *args[, key], there could be many optional args and one optional key.

but i would like to know all variations to these.

one more i saw,

itertools.accumulate(iterable[, func, *, initial=None])

maybe it means, func is optional argument, and initial is optional keyword argument

apostofes
  • 2,959
  • 5
  • 16
  • 31

1 Answers1

1
max(iterable, *[, key, default])

The key and default are both optional, and must be specified keyword-only.

max(arg1, arg2, *args[, key])

Can be called with arbitrarily many arguments (at least 2) and key must be specified by keyword (since it comes after the *).

iter(object[, sentinal])

sentinal is optional.

input([prompt])

prompt is optional.

wim
  • 338,267
  • 99
  • 616
  • 750