I have an object with a huge list somewhere down in the bowels. The object's dump (e.g. using print(o)) doesn't fit on one screen.

But if I could manage to have members that are 1-D lists printed comma-separated on one line, the object would be easier to inspect.

How can this be achieved?


EDIT:

Found out that the object I was trying to display had a __repr__ that explicitly showed it's array content in a vertical manner... So this question may be closed.

有帮助吗?

解决方案 3

Found out that the object I was trying to display had a repr that explicitly showed it's array content in a vertical manner... So this question may be closed.

On regular python lists, arrays are printed on one line.

A snippet to show this.

其他提示

Most of time this gives a readable output:

import pprint
pprint.pprint(o)

Try doing ", ".join(my_long_list).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top