Is there idiomatic python way to list all combinations of specific size from a list?
The following code works in ruby (here), I wonder if there is python equivalent for this:
a = [1, 2, 3, 4]
a.combination(1).to_a #=> [[1],[2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
PS: I am not looking for permutations, but combinations of specific size.
Thanks a lot : )