10 Oct 01:08
Documentation idea
From: Raymond Hettinger <python <at> rcn.com>
Subject: Documentation idea
Newsgroups: gmane.comp.python.devel
Date: 2008-10-09 23:12:40 GMT
Subject: Documentation idea
Newsgroups: gmane.comp.python.devel
Date: 2008-10-09 23:12:40 GMT
Background ---------- In the itertools module docs, I included pure python equivalents for each of the C functions. Necessarily, some of those equivalents are only approximate but they seem to have greatly enhanced the docs. Something similar is in the builtin docs for any() and all(). The new collections.namedtuple() factory function also includes a verbose option that prints a pure python equivalent for the generated class. And in the decimal module, I took examples directly from the spec and included them in doc-testable docstrings. This assured compliance with the spec while providing clear examples to anyone who bothers to look at the docstrings. For itertools docs, I combined those best practices and included sample calls in the pure-python code (see the current docs for itertools to see what I mean -- perhaps look at the docs for a new tool like itertools.product() or itertools.izip_longest() to see how useful it is). Bright idea ---------- Let's go one step further and do this just about everywhere and instead of putting it in the docs, attach an exec-able string as an attribute to our C functions. Further, those pure python examples should include doctests so that the user can see a typical invocation and calling pattern. Say we decide to call the attribute something like ".python", then you could write something like:(Continue reading)
RSS Feed