new in programing

Dan Bishop danb_83 at yahoo.com
Sat Dec 10 01:03:07 CET 2005


Cameron Laird wrote:
...
>   for hextuple in [(i, j, k, l, m, n)
>          for i in range(1, lim + 1) \
>          for j in range (1, lim + 2) \
>          for k in range (1, lim + 3) \
>          for l in range (1, lim + 4) \
>          for m in range (1, lim + 5) \
>          for n in range (1, lim + 6)]:
>       print hextuple
>
> I don't think the list comprehension helps, in this case--although
> it hints at the temptation of an eval-able expression which is
> briefer.  More on that, later.

from the recent "N-uples from list of lists" thread import cross

for hextuple in cross(*[xrange(1, lim+p) for p in xrange(1, 7)]):
   print hextuple




More information about the Python-list mailing list