Creating unique combinations from lists

Tim Chase python.list at tim.thechases.com
Wed Jan 16 17:51:39 EST 2008


>>   for a in range(5):
> ...
>>                            for z in range(5):
> 
> means the inner loop runs 5**26 times so perhaps it's not only
> unpythonic but also uncomputable...

only if you're impatient ;)

yes, it was a contrived pessimal example.  It could be range(2) 
to generate boolean-number sequences.  I've done 2**26 loops in 
code before (well, it was on the way to 2**32, just to see how 
long it took to roll over and hit an error condition).

The main emphasis was to show that there was a pattern unfolding 
that should have been translated into more pythonic code than 
just hard-coding nested loops.

-tkc






More information about the Python-list mailing list