Number Sequencing, Grouping and Filtering

Chris Rebert clp2 at
Tue Mar 10 11:07:32 CET 2009

On Tue, Mar 10, 2009 at 3:00 AM, flebber <flebber.crue at> wrote:
> On Mar 10, 8:54 pm, flebber <flebber.c... at> wrote:
>> Hi
>> I was hoping someone would be able to point me in the direction of
>> some good documentation regarding sequencing, grouping and filtering
>> and in which order they should be done.
>> As a small example it is easy to create the range of numbers 1 to 20.
>> But if I wanted to group all possible combinations of sets of 4
>> numbers within this range is there already an in uilt function for
>> this I am searching the module docs with "number sequencing" and
>> "number grouping" but cannot find info.
>> Then if I wanted to refine this results further eg no consecutive
>> numbers to be contained in sets. Is it best to create all sets and
>> then filter the sets for things matching this criteria or to set this
>> condition in a creation. Creating sets and then filtering would soon
>> become unwieldy with a larger range I would imagine..
>> An ideas, pointers to docs or better search terms to help me explore
>> this further would be appreciated.
>> Thanks Sayth
> I have just found itertools is this acheivable using combinations()
> and groupby() in itertools?

Yes; indeed, those were the functions your post brought to mind and
which led me to suggest itertools.


I have a blog:

More information about the Python-list mailing list