Re:A Pirate's Guide to Accuracy, Precision, Recall, and Othe...
by _raoulcousins on Monday November 18, 2019 @11:53AM
(#21565842)
Not the point of the article, but what's the idiomatic way to generate [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]? The author's [1 for n in range(10)]? [1 for _ in range(10)]? [1]*10?
[ Parent
| on HN ]
Re:A Pirate's Guide to Accuracy, Precision, Recall, and Othe...
by mason_jake on Monday November 18, 2019 @12:03PM
(#21565937)
Python dev for 5 years: personally I like `[1 for _ in range(10)]` and `[1] * 10`. The `for _ in` syntax denotes the variable is basically a throwaway, whereas the `for n in` construct is a bit confusing - almost like we're supposed to be doing something with the `n` in the comprehension.
Re:A Pirate's Guide to Accuracy, Precision, Recall, and Othe...
by contravariant on Monday November 18, 2019 @01:13PM
(#21566605)
All those options are pretty idiomatic. You can also use itertools to write it as `list(it.repeat(1, 10))`. Optionally you can leave out the `list` if you don't need it (which is the main reason to use itertools).