Filling a space...

Emile van Sebille emile at fenx.com
Tue Jun 11 23:17:21 EDT 2002


"Thor" <thor__00 at yahoo.com> wrote in message
news:ae4v9h$3qg34$9 at ID-108351.news.dfncis.de...
> Having this tupe: (2,3,4), which one would be the msot efficient way
to get
> this (parentheses ommited):
>
> 0,0,0  0,0,1  0,0,2  0,0,3
> 0,1,0  0,1,1  0,1,2  0,1,3
> 0,2,0  0,2,1  0,2,2  0,2,3
> 1,0,0  1,0,1  1,0,2  1,0,3....
>

>>> t = (2,3,4)
>>> [(a,b,c) for a in range(t[0]) for b in range(t[1]) for c in
range(t[2])]

I think I needed this once for a variable length tuple and parameterized
it further...

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list