This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Recursive Repr
Type: enhancement Stage:
Components: Versions: Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, rhettinger
Priority: normal Keywords: patch

Created on 2010-09-12 22:13 by rhettinger, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
recursive_repr.patch rhettinger, 2010-09-12 22:13 Patch with test and docs
Messages (4)
msg116239 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-09-12 22:13
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.
msg116257 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-13 00:13
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 #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?)
msg116353 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-09-13 21:37
Committed in r84792.
msg133047 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-04-05 16:21
FTR, the answer to my interrogation in my previous message is contained in Raymond’s PyCon talk about API design: :)
Date User Action Args
2022-04-11 14:57:06adminsetgithub: 54049
2011-04-05 16:21:30eric.araujosetmessages: + msg133047
2010-09-13 21:37:17rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg116353
2010-09-13 00:13:08eric.araujosetnosy: + eric.araujo
messages: + msg116257
2010-09-12 22:13:18rhettingercreate