[issue16801] Preserve original representation for integers / floats in docstrings

Carsten Klein report at bugs.python.org
Sat Dec 29 13:59:04 CET 2012


Carsten Klein added the comment:

The problem with this is that at the time that pydoc gets the information via inspect, the numbers have already been parsed as long or double and the original notation is no longer available.

This is due to the fact that during build of the AST node for the NUMBER type, the value will already be deserialized into its machine representation, which is either long or double.

The only way to preserve that information would be to extend the NUM_type with an additional 's' field which then would preserve its original notation and which can be retrieved from the AST.

pydoc, however, would still fail as it does not use the AST. In order to restore the original information, pydoc must then source the original file or source of the function or class method and parse it using the AST.

A much simpler approach would be to simply get the function or method source and extract its formal parameter list using for example a regular expression.

However, preserving the original notation in the runtime is not required and shouldn't be done.

----------
nosy: +carsten.klein at axn-software.de

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16801>
_______________________________________


More information about the Python-bugs-list mailing list