__doc__ regression
Hello, Following the previous clinic thread, I realize that the latest signature improvements actually entail a regression in __doc__. Compare: $ ./python -c "print(dict.fromkeys.__doc__)" Returns a new dict with keys from iterable and values equal to value. $ python3.3 -c "print(dict.fromkeys.__doc__)" dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v. v defaults to None. As you see the signature string has vanished from the __doc__ contents. This means that any tool directly processing __doc__ attributes to generate (e.g.) automatic API docs will produce less useful docs. I think the signature should be restored, and a smarter way of reconciling __doc__ and the signature for help() should be found. Regards Antoine.
On 02/04/2014 04:17 AM, Antoine Pitrou wrote:
As you see the signature string has vanished from the __doc__ contents. This means that any tool directly processing __doc__ attributes to generate (e.g.) automatic API docs will produce less useful docs.
Why couldn't these tools use inspect.Signature? //arry/
2014-02-04 Larry Hastings
Why couldn't these tools use inspect.Signature?
inspect.Signature was added in Python 3.3. Python 2 is still widely used, and some Linux distro only provide Python 3.2. By the way, help(dict.fromkeys) looks to use __doc__, not the signature, because the prototype is also missing. It's a regression. Victor
Am 04.02.2014 14:19, schrieb Victor Stinner:
2014-02-04 Larry Hastings
: Why couldn't these tools use inspect.Signature?
inspect.Signature was added in Python 3.3. Python 2 is still widely used, and some Linux distro only provide Python 3.2.
Well, Python 2 won't be able to introspect C modules written and compiled for Python 3.x anyway. And __text_signature__ can be used by any Python 3.x with no loss of expressivity (handling strings in both cases). Georg
On 02/04/2014 05:19 AM, Victor Stinner wrote:
2014-02-04 Larry Hastings
: Why couldn't these tools use inspect.Signature? inspect.Signature was added in Python 3.3. Python 2 is still widely used, and some Linux distro only provide Python 3.2.
By the way, help(dict.fromkeys) looks to use __doc__, not the signature, because the prototype is also missing.
It's a regression.
In 3.4, inspect.getfullargspec and inspect.getargspec are being reimplemented using inspect.Signature. I don't understand your bringing up Python 2 and Python 3.2. Are there programs that run under Python 2 and Python 3.2 that examine docstrings from Python 3.4? //arry/
On Tue, 04 Feb 2014 05:08:28 -0800
Larry Hastings
On 02/04/2014 04:17 AM, Antoine Pitrou wrote:
As you see the signature string has vanished from the __doc__ contents. This means that any tool directly processing __doc__ attributes to generate (e.g.) automatic API docs will produce less useful docs.
Why couldn't these tools use inspect.Signature?
Because it's new in 3.3? Most Python code has been written before that. Regards Antoine.
On 02/04/2014 05:24 AM, Antoine Pitrou wrote:
On Tue, 04 Feb 2014 05:08:28 -0800 Larry Hastings
wrote: On 02/04/2014 04:17 AM, Antoine Pitrou wrote:
As you see the signature string has vanished from the __doc__ contents. This means that any tool directly processing __doc__ attributes to generate (e.g.) automatic API docs will produce less useful docs. Why couldn't these tools use inspect.Signature? Because it's new in 3.3? Most Python code has been written before that.
inspect.getargspec and inspect.getfullargspec in 3.4 use inspect.Signature to get the signatures of builtins. Does this address your concerns? //arry/
participants (4)
-
Antoine Pitrou
-
Georg Brandl
-
Larry Hastings
-
Victor Stinner