Re:Comparing the Same Project in Rust, Haskell, C++, Python,...
by tanin on Sunday June 16, 2019 @12:28AM
(#20193839)
While what you say is true, my small example shows that the code is longer in Python for solving the same problem, i.e. `my_list[0] if my_list else None` is longer than `my_list.headOption` or `my_list.first`.
And we are talking about the brevity of a language here.
(1) It shows Python expresses the concept fairly compactly in the core language without even resorting to stdlib,
(2) It ignores an option (also in the core language) using a ternary and the truthiness of lists: my_list[0] if my_list else None