def foo():
    """
    >>> foo() 
    [...] world
    """
print('hello world')
if __name__ == '__main__':
    import doctest
OC = doctest.OutputChecker


class AEOutputChecker(OC):

    def check_output(self, want, got, optionflags):
        from re import sub
if optionflags & doctest.ELLIPSIS:
    want = sub('\\[\\.\\.\\.\\]', '...', want)
return OC.check_output(self, want, got, optionflags)
doctest.OutputChecker = AEOutputChecker
doctest.testmod()
Can I have an ellipsis at the beginning of the line in a Python doctest?