Replies: 2 comments 4 replies
-
I'm not sure I fully understand your question, but you might find the Rich Repr Protocol section helpful in the docs about Pretty Printing. |
Beta Was this translation helpful? Give feedback.
1 reply
-
I use that regularly, but my question is how to use the built-in formatting, for situations such as the following: class Test:
def __init__(self, **kwargs):
self.kwargs = kwargs
self.__repr__ = self.kwargs.__repr__ Rich doesn't seem to use the repr for the built-in type. Is there any way to achieve this sort of functionality? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
Sorry, I'm having trouble explaining exactly what I want, but is there any way for a class not inheriting from, say, a dict, to have the repr of the dict? For example, when pretty printing a dictionary, larger dictionaries are expanded by default, but doing something like
self.__repr__ = self.dct.__repr__
doesn't seem work, and the built-in dict type obviously has no__rich_repr__
for me to copy. Is there any way to get the same default expansion for user classes?Thank you kindly for the help!
Beta Was this translation helpful? Give feedback.
All reactions