Is there a way to make PyCharm debugger display items of a custom-made sequence-like object?
I would like it to be the default view, without resorting to displaying list(x)
.
Example custom Sequence object:
class WrappedList(Sequence):
def __init__(self, wrapped_list):
self.wrapped_list = wrapped_list
def __getitem__(self, i):
return self.wrapped_list[i]
def __len__(self) -> int:
return len(self.wrapped_list)
def __repr__(self):
return f'WrappedList({self.wrapped_list})'
PyCharm displays it like this:
I would like it to be displayed like a collection of elements:
Note: This doesn't seem to be that important in this simple example, but when the object is implemented in C code there is no easy way to get to the contents from a watch window, as there is no embedded
wrapped_list
field to look at: