amarao: (Default)
amarao ([personal profile] amarao) wrote2023-03-01 05:06 pm

batteries included, сказал питон

[[1,2], [3,4]].flatten()
               ^ ERROR: Flatten is not a battery. That's why it's not in the Python.
juan_gandhi: (Default)

[personal profile] juan_gandhi 2023-03-01 04:17 pm (UTC)(link)

FP not available. As Guido said, he does not know categories, and has no plans to learn.

yurikhan: (Default)

[personal profile] yurikhan 2023-03-01 04:38 pm (UTC)(link)
In [6]: list(itertools.chain(*[[1, 2], [3, 4]]))
Out[6]: [1, 2, 3, 4]

In [7]: list(itertools.chain.from_iterable([[1, 2], [3, 4]]))
Out[7]: [1, 2, 3, 4]

ну или в лоб:

In [8]: [x for xs in [[1, 2], [3, 4]] for x in xs]
Out[8]: [1, 2, 3, 4]