Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Signature.__repr__ #64577

Closed
cool-RR mannequin opened this issue Jan 24, 2014 · 5 comments
Closed

Implement Signature.__repr__ #64577

cool-RR mannequin opened this issue Jan 24, 2014 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@cool-RR
Copy link
Mannequin

cool-RR mannequin commented Jan 24, 2014

BPO 20378
Nosy @terryjreedy, @cool-RR, @1st1

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/1st1'
closed_at = <Date 2014-03-27.16:42:21.087>
created_at = <Date 2014-01-24.14:05:52.658>
labels = ['library']
title = 'Implement `Signature.__repr__`'
updated_at = <Date 2014-03-27.16:42:21.085>
user = 'https://github.com/cool-RR'

bugs.python.org fields:

activity = <Date 2014-03-27.16:42:21.085>
actor = 'python-dev'
assignee = 'yselivanov'
closed = True
closed_date = <Date 2014-03-27.16:42:21.087>
closer = 'python-dev'
components = ['Library (Lib)']
creation = <Date 2014-01-24.14:05:52.658>
creator = 'cool-RR'
dependencies = []
files = []
hgrepos = []
issue_num = 20378
keywords = []
message_count = 5.0
messages = ['209112', '209114', '209455', '209456', '214966']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'cool-RR', 'python-dev', 'yselivanov']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue20378'
versions = ['Python 3.5']

@cool-RR cool-RR mannequin added the stdlib Python modules in the Lib dir label Jan 24, 2014
@terryjreedy
Copy link
Member

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.

@cool-RR
Copy link
Mannequin Author

cool-RR mannequin commented Jan 24, 2014

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.

@1st1
Copy link
Member

1st1 commented Jan 27, 2014

Ram, yes, I agree. Something like '<Signature f: alpha, beta=3, *args, **kwargs>' should work.

@1st1 1st1 self-assigned this Jan 27, 2014
@cool-RR
Copy link
Mannequin Author

cool-RR mannequin commented Jan 27, 2014

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.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 27, 2014

New changeset 3f9a81297b39 by Yury Selivanov in branch 'default':
inspect.signature: Improve repr of Signature and Parameter. Closes bpo-20378
http://hg.python.org/cpython/rev/3f9a81297b39

@python-dev python-dev mannequin closed this as completed Mar 27, 2014
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants