Why is there a comma after the bracket for optional arguments in the Python Docs function?

The format of function signatures in Python docs is a bit confusing. What is the value when placing a comma after an open bracket, and not earlier? What is the meaning of nesting brackets?

How are they:

RegexObject.match(string[, pos[, endpos]])

I would expect one of the following:

RegexObject.match(string, [pos], [endpos])
RegexObject.match(string[, pos][, endpos])
+5
source share
5 answers

A square bracket means that the content is optional, but everything outside the square brackets is mandatory.

With your notation:

RegexObject.match(string, [pos], [endpos])

I would expect to write:

r.match("foo",,)

, , , . - :

RegexObject.match(string[, pos][, endpos])
+16

. , , pos ().

+2

, , . , , , . , :

RegexObject.match(string, [pos], [endpos])

:

RegexObject.match("foobar",,)

.

+2

, , . , , , .

0

, . , , , , RegexObject.match(string,), . RegexObject.match(string, endpos), . . endpos, . , , endpos. , , .

0

All Articles