ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> doc-sig
doc-sig
[Doc-SIG] Proposal: don't nest optional brackets
by A.M. Kuchling other posts by this author
Jun 20 2008 5:42AM messages near this date
Educating the young on ways on have fun | Re: [Doc-SIG] Proposal: don't nest optional brackets
To show a series of optional parameters, currently we nest square
brackets.

http://docs.python.org/dev/library/warnings.html#warnings.filterwarnings

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][, l
ineterm])

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?

--amk
_______________________________________________
Doc-SIG maillist  -  Doc-SIG@[...].org
http://mail.python.org/mailman/listinfo/doc-sig
Thread:
A.M. Kuchling
Georg Brandl
Mark Sapiro
Paul Moore

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved