The resulting string has a string (and I believe this syntax violates the bending function in my IDE):
>>> def linebreak(): >>> return """Hello this is a really long string which eventually >>> needs to be breaked due to line length""" >>> print(linebreak()) Hello this is a really long string which eventually needs to be breaked
This is better, but it not only includes line breaks, but also includes many spaces in the resulting line:
>>> def whitespace(): >>> some_string = """Hello this is a really long string which eventually >>> needs to be breaked due to line length""" >>> print(whitespace()) Hello this is a really long string which eventually needs to be breaked
As suggested in this SO Q / A , you should carefully format each line (which is very tedious) to make sure you finish or start with a space. If you manage to edit a line after its initial creation, you can also get lines of text with a very odd line length (imagine 10 lines of text of different lengths):
>>> def tedious(): >>> return ('Hello this is a really long string which eventually ' >>> 'needs to be breaked due to line length') >>> print(tedious()) Hello this is a really long string which eventually needs to be breaked due to line length
What is the general opinion on how to identify long lines with PEP-8 in mind and without explicitly highlighting lines or spaces, where do I define them?
This is super collapsed, but it seems to do what I want, although it makes it impossible to explicitly define the string:
>>> def hello(): >>> return ' '.join("""Hello this is a really long string which >>> eventually needs to be breaked due to line >>> length""".split()) >>> print(hello()) >>> Hello this is a really long string which eventually needs to be breaked due to line length
Question: Any suggestions for improving this last confusing approach?
source share