
Lists of lines in programs are common. For readability, they are no less often formatted vertically, one by one. And there is a vulnerability in such a construction - if a comma is lost between elements, then many languages simply merge lines to the left and right of the missing comma - the result is a valid list in terms of language, in which one element is less than expected and one element has an incorrect value. There are many ways to prevent this problem, but recently I was shown on stackoverflow in such a simple and reliable way that I just can’t share it.
Demonstration of the problem
')
First, let's see visually how the problem looks. A typical vertical list in which a comma is lost:
languages = [
"english",
"russian",
"italian"
"spanish" ]
, «italian» «spanish» . : Python «italian» «spanish», :
languages = [ "english", "russian", "italianspanish" ]
— .
-
c , lint . — pylint . , , , . pylint + autobuild, continous integration .
. , , , . :
languages = [
"english",
"russian",
"italian",
"spanish",
]
, — .
, . , :
languages = [
"english"
, "russian"
, "italian"
, "spanish"
]
( - , )
. . — .
stackoverflow. — . . — epression expression, :
languages = [
("english"),
("russian"),
("italian")
("spanish") ]
. , - . , :)