[Python-Dev] Additional behaviour for itertools.combinations

Konrad Delong konryd at gmail.com
Sat Jan 24 21:00:25 CET 2009


I'm not sure if it's the right place to post it. If so - I'll be glad
to learn where is one.
Anyway:
I think the function itertools.combinations would benefit from making
the 'r' (length of the combinations) argument optionally a sequence.

With that change one could call combinations(sequence, [2, 3]) in
order to get all combinations of length 2 and 3.
In particular, one could call combinations(sequence,
range(len(sequence)) in order to get *all* combinations of given
sequence.

The change would be backwards compatible as it would check for
sequential arguments.

Is it worth the shot?

best regards
Konrad

PS. Didn't want to spoil the beginning of the post, but I consider it
to be a good practice to introduce oneself when posting the first
time, so: Hello, my name is Konrad, I'm an IT student and I'm
following python-dev for some time, but never posted before.


More information about the Python-Dev mailing list