0
Can a sentence in Python finally be written in multiple lines?
I thought in Python a sentence should be always written in one line, and in this example (with '{}' in multiple lines) it is exactly like a hash-like way in Perl, only except without a final ';'. Must the indent be like that, or can be changed somehow? Is this still deemed as one sentence?
2 Answers
+ 2
Python uses "statements"; a "sentence" is related to text/strings (the other answer takes that route).
Line continuation (across multiple lines) for statements occurs implicitly with [, (, and { at least. It's explicit if you end a line with \ (which works inside strings and doesn't need to be closed like brackets do).
https://www.python.org/dev/peps/pep-0008/#block-comments
That style guide discusses how to line up the ending ])} and code inside the brackets.
0
You may use: #1:
s = â â â this is a very
long line if you want to
write in python and more ......... â â â
Or you may use: #2:
s = (â this is a veryâ
â long line if you want toâ
âwrite in python and more ......... â