[Doc-SIG] Proposal: don't nest optional brackets

A.M. Kuchling amk at amk.ca
Fri Jun 20 14:41:40 CEST 2008

To show a series of optional parameters, currently we nest square


warnings.filterwarnings(action[, message[, category[, module[,
lineno[, append]]]]])

My proposal is that we drop the nesting and write this as:

warnings.filterwarnings(action [, message, category, module, lineno, append])

Currently the stylesheets make the brackets very big and dark, so I've
also added a space before the bracket.

This change means we'd lose the ability to show when two optional
arguments must be supplied at the same time, which could currently be
written like this:

warnings.filterwarnings(action[, message, category[, module]])

In this hypothetical example, if you supply 'message' you must also
supply 'category'.  But I think that for most functions, you can
supply each optional argument or not; you rarely need to supply two
optional arguments that are tied in this way, and we can handle such
cases by adding a sentence such as "Both message and category parameters 
must be supplied."  

A few places (difflib, doctest, probably others) use this format:

.. function:: context_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm])

It's better than the nested version -- at least it avoids the ]]]]])
at the end -- but I think having a single set of square brackets also
works and reduces the symbolic noise further.

.. function:: context_diff(a, b [, fromfile, tofile, fromfiledate, tofiledate, n, lineterm])

The brackets are large enough that I think this would still be quite
readable; it doesn't seem likely that readers will miss that these
parameters are optional.

What does everyone think?


More information about the Doc-SIG mailing list