Define different output for the _repr_ method when printing a list of objects

94 views Asked by At

I have a custom class which has implemented the _repr_ method, printing out all the properties of this object, for example:

Id: XXX,
Name: XXX 
PropA: XXX,
PropB: XXX,
PropC: XXX ...

Problem -

Is there a way to change the output to return only a subset of the properties, when printing a list of these objects, for example:

Id: XXX,
Name: XXX 

My Ideology -The only possible way I can think of implementing this would be to implement a custom list class for the object which implements the less detailed output of _repr_, however, I would rather avoid this if possible.

0

There are 0 answers