I often see examples that use doctest.ELLIPSIS
to limit output in interactive examples of Python use,
>>> print range(20) # doctest:+ELLIPSIS
[0, 1, ..., 18, 19]
and see here how to enable the feature in modules; but I can't figure out how to enable this feature interactvely.
How do I enable doctest.ELLIPSIS
at the Python or IPython prompt?
It's not limiting the output, it's telling doctest it doesn't need to check all of it. That line of code will still produce the full output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
But doctest will only check the bits before and after the ...
.
I don't know of anything to limit the output like that in interactive sessions, though if you use Python 3, you could write your own implementation of print()
to do it.