@@ -49,16 +49,20 @@ class RESTObject:
4949 another. This allows smart updates, if the object allows it.
5050
5151 You can redefine ``_id_attr`` in child classes to specify which attribute
52- must be used asuniq ID. ``None`` means that the object can be updated
52+ must be used asthe unique ID. ``None`` means that the object can be updated
5353 without ID in the url.
54+
55+ Likewise, you can define a ``_repr_attr`` in subclasses to specify which
56+ attribute should be added as a human-readable identifier when called in the
57+ object's ``__repr__()`` method.
5458 """
5559
5660_id_attr :Optional [str ]= "id"
5761_attrs :Dict [str ,Any ]
5862_created_from_list :bool # Indicates if object was created from a list() action
5963_module :ModuleType
6064_parent_attrs :Dict [str ,Any ]
61- _short_print_attr :Optional [str ]= None
65+ _repr_attr :Optional [str ]= None
6266_updated_attrs :Dict [str ,Any ]
6367manager :"RESTManager"
6468
@@ -158,10 +162,19 @@ def pprint(self) -> None:
158162print (self .pformat ())
159163
160164def __repr__ (self )-> str :
165+ name = self .__class__ .__name__
166+
167+ if (self ._id_attr and self ._repr_attr )and (self ._id_attr != self ._repr_attr ):
168+ return (
169+ f"<{ name } { self ._id_attr } :{ self .get_id ()} "
170+ f"{ self ._repr_attr } :{ getattr (self ,self ._repr_attr )} >"
171+ )
161172if self ._id_attr :
162- return f"<{ self .__class__ .__name__ } { self ._id_attr } :{ self .get_id ()} >"
163- else :
164- return f"<{ self .__class__ .__name__ } >"
173+ return f"<{ name } { self ._id_attr } :{ self .get_id ()} >"
174+ if self ._repr_attr :
175+ return f"<{ name } { self ._repr_attr } :{ getattr (self ,self ._repr_attr )} >"
176+
177+ return f"<{ name } >"
165178
166179def __eq__ (self ,other :object )-> bool :
167180if not isinstance (other ,RESTObject ):