Message80506
> that dropping the length argument will make the function iterate over
> *all* combinations,
Now *this* sounds more useful to me: an itertool that generates *all* subsets of a list. It's
quite easy to do with existing itertools, though, either by looping over the second argument to
combinations, or (for a different ordering) using product:
def subsets(iterable):
l = list(iterable)
for selector in itertools.product([False, True], repeat=len(l)):
yield [element for indicator, element in zip(selector, l) if indicator] |
|
Date |
User |
Action |
Args |
2009-01-25 13:08:37 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, ezio.melotti, konryd |
2009-01-25 13:08:37 | mark.dickinson | set | messageid: <1232888917.62.0.521655481338.issue5048@psf.upfronthosting.co.za> |
2009-01-25 13:08:37 | mark.dickinson | link | issue5048 messages |
2009-01-25 13:08:36 | mark.dickinson | create | |
|