What you want is to add display support to existing object (example with polynomial and TeX) (those you can't tamper the source with) what you are trying to define is a "pretty Formatter" (aka _repr_pretty_
) for those. You will have a difficulty compared to numpy arrays which is that list are heterogeneous, and so the first element can be a really supper long element.
You can also look at the plain doc for existing formatters, to get an idea.