Include a helper for writing `__repr__` in the standard library
Discussions on Python.org
Include a helper for writing `__repr__` in the standard library
I have wanted this a few times and I’m curious whether others would find this useful. For this class: class Point: def __init__(self, x, y, z, color): self.x, self.y, self.z = x, y, z self.color = color def __repr__(self): return f"{type(self).__name__}({self.x!r}, {self.y!r}, {self.z!r}, color={self.color!r})" I’m imagining replacing the __repr__ method with this: from reprlib import make_repr class Point: def __init__(self, x, y, z, color): sel...
0 comments
No comments yet.