0

I have been looking at the documentation for the Python datetime library, and I am confused by the call signatures. For example, datetime.timedelta can be called in the following way

datetime.timedelta(10, 68400)

However, its call signature is documented as

datetime.timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]])

I am uncertain how to interpret the nested lists in the call signature, and how they relate to the ways in which you can call timedelta.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
xvtk
  • 1,030
  • 2
  • 10
  • 18

1 Answers1

0

There is a related answer here, and is basically a duplicate of your question: What do square brackets, "[]", mean in function/class documentation?

Either you can give the options in order, for example: timedelta(1, 2, 3) for 1 day, 2 seconds and 3 microseconds, or you specify by the arguments you're interested in: timedelta(days=1, microseconds=4) and this allows you to put them in any order, and/or omit the options you don't need.

Edit: OK I think this is the answer: Why do Python function docs include the comma after the bracket for optional args?

Community
  • 1
  • 1
Oceanic_Panda
  • 112
  • 1
  • 13
  • The implementation would just be timedelta(*args, **kwargs), yes? From your answer, I understand how to use "timedelta". However, why denote the signature with nested lists with leading commas? I don't understand the significance of that notation. – xvtk Apr 07 '17 at 13:54
  • Agreed on timedelta(*args, **kwargs), unfortunately as to the point of your question that stumps me as well. – Oceanic_Panda Apr 07 '17 at 14:51