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

Recursive Repr #54049

Closed
rhettinger opened this issue Sep 12, 2010 · 4 comments
Closed

Recursive Repr #54049

rhettinger opened this issue Sep 12, 2010 · 4 comments
Labels
type-feature A feature request or enhancement

Comments

@rhettinger
Copy link
Contributor

BPO 9840
Nosy @rhettinger, @merwok
Files
  • recursive_repr.patch: Patch with test and docs
  • 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 = None
    closed_at = <Date 2010-09-13.21:37:17.229>
    created_at = <Date 2010-09-12.22:13:18.603>
    labels = ['type-feature']
    title = 'Recursive Repr'
    updated_at = <Date 2011-04-05.16:21:30.780>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2011-04-05.16:21:30.780>
    actor = 'eric.araujo'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-13.21:37:17.229>
    closer = 'rhettinger'
    components = []
    creation = <Date 2010-09-12.22:13:18.603>
    creator = 'rhettinger'
    dependencies = []
    files = ['18862']
    hgrepos = []
    issue_num = 9840
    keywords = ['patch']
    message_count = 4.0
    messages = ['116239', '116257', '116353', '133047']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'eric.araujo']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue9840'
    versions = ['Python 3.2']

    @rhettinger
    Copy link
    Contributor Author

    Add a recursive_repr() decorator to provide a solution to the problem of creating a container __repr__ method that doesn't fail for recursive calls.

    @rhettinger rhettinger added the type-feature A feature request or enhancement label Sep 12, 2010
    @merwok
    Copy link
    Member

    merwok commented Sep 13, 2010

    Good idea. I wonder if the genericity (being able to specify the placeholder) is needed; the ellipsis is used by built-in containers (not documented AFAICT, see bpo-9842) and seems a good choice for most (all?) of the cases. What bothers me is that this simple, common case can’t just use @recursive_repr (without parens) which seems to me more natural.

    One markup glitch: :meth:`repr__` lacks two underscores.

    (Unimportant side question: Since collections defines __all__, why are imported names renamed with a trailing underscore?)

    @rhettinger
    Copy link
    Contributor Author

    Committed in r84792.

    @merwok
    Copy link
    Member

    merwok commented Apr 5, 2011

    FTR, the answer to my interrogation in my previous message is contained in Raymond’s PyCon talk about API design: http://pycon.blip.tv/file/4883290/ :)

    @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
    type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants