[Python-Dev] Additional behaviour for itertools.combinations
Nick Coghlan
ncoghlan at gmail.com
Sun Jan 25 02:18:23 CET 2009
Raymond Hettinger wrote:
> Since I expect students to be among the users for the comb/perm
> functions, there is some merit to keeping the API as simple as possible.
> Besides, it is not hard to use the existing tool as a primitive to get to
> the one you want:
>
> def mycombinations(iterable, r_seq):
> # mycombinations('abc', [1,2]) --> A B C AB AC BC
> iterable = list(iterable)
> return chain.from_iterable(imap(combinations, repeat(iterable),
> r_seq))
Perhaps a reasonable starting point would be to include this as one of
the example itertools recipes in the documentation?
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
More information about the Python-Dev
mailing list