Wrapping python doctest results that are longer than 80 characters

前端 未结 2 654
一整个雨季
一整个雨季 2020-12-29 20:29

I\'m trying to keep my source code under the 80 character guideline width that PEP8 recommends, but can\'t figure out how to wrap my doctest which has results longe

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 20:45

    Just figured out:

    def long_string():
        """
        Returns a string which is wider than the recommended PEP8 linewidth
    
        >>> print long_string()
        01234567890123456789012345678901234567890123456789012345678901234567890\
    12345678901234567890123456789
    
        """
        return '0123456789' * 10
    

    Hope that helps somebody else out.

提交回复
热议问题