5 ms·
As contrived as those examples are, Python does have one feature that I currently miss, which is that trailing commas are ignored. mylist = [ "ape",
by fragmede 17y ago
As contrived as those examples are, Python does have one feature that I currently miss, which is that trailing commas are ignored.
mylist = [
"ape",
"bat",
"cat",
]
- agazso 17y agoThis feature is also in C and in Go language. It makes especially easy to write code generators, because you don't have to deal with first/last special cases.
- RyanMcGreal 17y agoI love this feature, but it bites me in the ass every time I work in a language that doesn't support this - like javascript and SQL.
- jashkenas 17y agoIf you'd like trailing commas in your JavaScript, one of the tiny things that CoffeeScript does is allow trailing commas, or for commas to be omitted altogether on multi-line array and object literals. list: [ "ape", "bat", ] list: [ "ape" "bat" ] .. are the same.
- arohner 17y agoAnd in Clojure, all commas everywhere are whitespace. You can use them, or not use them, even on single line expressions. (list a b c) == (list a, b, c) == (list a b, c)