[Python-ideas] Optional static typing -- late to the party
Ben Finney
ben+python at benfinney.id.au
Wed Aug 20 14:53:24 CEST 2014
Steven D'Aprano <steve at pearwood.info> writes:
> But remember that any annotations in docstrings may not be available
> at runtime
How so? What conformant Python implementation is discarding docstrings
from code objects?
> Also, docstring annotations have the disadvantage of being text only,
> instead of expressions which evaluate to arbitrarily powerful or
> useful objects.
True. This is why I'm a fan of reStructuredText for docstrings, and the
conventions that have arisen for using reST field lists for code
annotations <URL:http://sphinx-doc.org/domains.html#info-field-lists>.
The structure in a docstring isn't available without parsing the reST,
but that seems no worse than requiring new syntax and new tools to
process function annotations.
I'm not arguing against function annotations, merely addressing these
claims about docstrings.
--
\ “The cost of a thing is the amount of what I call life which is |
`\ required to be exchanged for it, immediately or in the long |
_o__) run.” —Henry David Thoreau |
Ben Finney
More information about the Python-ideas
mailing list