The format of the function signatures in the Python docs is a bit confusing. What is the significance in putting the comma after the open bracket, rather than before? What is the significance of nesting the brackets?
How they are:
RegexObject.match(string[, pos[, endpos]])
I would expect one of the following:
RegexObject.match(string, [pos], [endpos])
RegexObject.match(string[, pos][, endpos])
The square brackets indicate that these arguments are optional. You can leave them out.
The indexing operator (Python uses square brackets to enclose the index) selects a single character from a string. The characters are accessed by their position or index value. For example, in the string shown below, the 14 characters are indexed left to right from postion 0 to position 13.
The square bracket means that the contents are optional, but everything outside of square brackets is compulsory.
With your notation:
RegexObject.match(string, [pos], [endpos])
I would expect to have to write:
r.match("foo",,)
The nesting is required because if you supply the third parameter then you must also supply the second parameter even though it is an optional parameter. The following non-nested alternative would be ambiguous:
RegexObject.match(string[, pos][, endpos])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With