3 ms·
Isn't things = [ 'foo', 'bar', 'baz', ] even better? In your case, if you want to add something to the beginning of the list you'll have to mo
by aflag 5y ago
Isn't
things = [
'foo',
'bar',
'baz',
]
even better? In your case, if you want to add something to the beginning of the list you'll have to modify two lines.
- jeffbee 5y agoDepending on the context, yes. But sometimes you are not allowed the last comma. ETA: Let me expand on why it's important to put the comma first. Which list is more clear to you: a , dog , weather , banana , b , car or a, dog, weather, banana, b, car With the leading commas, they all line up, and you can see them in a neat little row. I really prefer it especially in contexts where the trailing comma is not permitted, such as a SQL query: SELECT name , date , operation FROM stuff