Multiline strings
Briefly

The article discusses how to implement multiline strings in Python, illustrating this with a timer script called stopwatch.py. It explains how to create a usage statement with multiple lines of text and describes the use of string concatenation to enhance readability. However, it highlights the effectiveness of using Python's built-in multiline string syntax, which allows developers to write long strings without worrying about concatenation and line breaks. This makes the code cleaner and easier to understand.
This usage statement is represented by multiple lines of text in a single string. usage = "Welcome to stopwatch! \n This script counts slowly upward, \n one second per tick. \n\n No command-line arguments are accepted.".
We could make this code a little bit more readable by breaking this string up into substrings and then concatenating each of these substrings together.
Now, notice these parentheses, those are necessary to tell Python that these lines are all a continuation of just one line of code. That's called an implicit line continuation.
This is a multiline string: usage = """Welcome to stopwatch! This script counts slowly upward, one second per tick. This script does not accept command-line arguments.""".
Read at Pythonmorsels
[
|
]