Issue20378
Created on 2014-01-24 14:05 by cool-RR, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg209112 - (view) | Author: Terry J. Reedy (terry.reedy) * | Date: 2014-01-24 19:48 | |
Signature.__repr__ already exits. It is inherited from object. So you must be proposing to override the inherited method. For what purpose? With what outcome? Without reading the signature PEP, I believe the current difference between str and repr is intentional, not accidental. Example: >>> repr(s) '<inspect.Signature object at 0x02E7BC08>' >>> str(s) '(self, a)' If so, this issue should be closed unless you can provide an excellent reason to break code the expects the current behavior. |
|||
| msg209114 - (view) | Author: Ram Rachum (cool-RR) * | Date: 2014-01-24 19:55 | |
My impression is that the `__repr__` method of any object is intended to describe that object, hopefully in a succinct way, possibly in a REPL-friendly way (like `list.__repr__` for example) but if not then at least human-friendly. This is for easy introspection. When I come across a Signature object in the shell, I want to immediately get a good feel for what it contains without exploring `vars(sig)` manully. If you have a `Signature` object, why not have its `__repr__` return something like '<Signature f: alpha, beta=3, *args, **kwargs>`? This would do an awesome job at helping me understand what kind of signature object I'm looking at. |
|||
| msg209455 - (view) | Author: Yury Selivanov (yselivanov) * | Date: 2014-01-27 18:10 | |
Ram, yes, I agree. Something like '<Signature f: alpha, beta=3, *args, **kwargs>' should work. |
|||
| msg209456 - (view) | Author: Ram Rachum (cool-RR) * | Date: 2014-01-27 18:12 | |
If you'd like to expand this issue's scope to all the objects related to Signature, I think that'll be good. All objects need good introspection strings. |
|||
| msg214966 - (view) | Author: Roundup Robot (python-dev) | Date: 2014-03-27 16:42 | |
New changeset 3f9a81297b39 by Yury Selivanov in branch 'default': inspect.signature: Improve repr of Signature and Parameter. Closes #20378 http://hg.python.org/cpython/rev/3f9a81297b39 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:57 | admin | set | github: 64577 |
| 2014-03-27 16:42:21 | python-dev | set | status: open -> closed nosy:
+ python-dev resolution: fixed |
| 2014-01-27 18:12:54 | cool-RR | set | messages: + msg209456 |
| 2014-01-27 18:10:49 | yselivanov | set | assignee: yselivanov messages: + msg209455 |
| 2014-01-24 19:55:33 | cool-RR | set | messages: + msg209114 |
| 2014-01-24 19:48:49 | terry.reedy | set | nosy:
+ terry.reedy, yselivanov messages:
+ msg209112 |
| 2014-01-24 14:05:52 | cool-RR | create | |