Reputation: 49
So I have this code that i want to wrap, and i have looked for solutions, most people say to use '\' but when i print the msg from the exception, it splits the string with the new line character
raise specialExceptions.ConnectError("There was a \
connect issue")
this prints as:
There was a
connect issue
I want to wrap the code but output it as one line, how do i do this. thanks
Upvotes: 1
Views: 1768
Reputation: 531265
Use implicit string concatenation.
raise specialExceptions.ConnectError("There was a "
"connect issue")
Two string literals appearing adjacent to one another will be merged into a single string. The two literals can appear on different lines; intervening whitespace is not counted, due to Python's implicit line continuation inside parentheses.
Upvotes: 4
Reputation: 1669
Just enclose the strings with quotes on each line This shall work:
raise specialExceptions.ConnectError("There was a "
"connect issue")
Upvotes: 2