2

I don't know how to interpret this notation:

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

Source: https://docs.python.org/2/library/datetime.html#timedelta-objects

I'm using this function with a single keyword argument without inconvenience but I can't understand the reason of this notation ¿Does it have a name? Sorry if this is a duplicate post but I don't know how to google it.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Juan David
  • 2,676
  • 4
  • 32
  • 42

1 Answers1

10

This notation is described in the documentation introduction:

a phrase enclosed in square brackets ([ ]) means zero or one occurrences (in other words, the enclosed phrase is optional).

The documentation you link to also explains the parameters:

All arguments are optional and default to 0. Arguments may be ints, longs, or floats, and may be positive or negative.


The short version: If a parameter is enclosed in square brackets, it is optional.

Andy
  • 49,085
  • 60
  • 166
  • 233