On Thu, May 29, 2008 at 8:16 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:
> Hi,
>
> i am using a software which uses python as its scripting language. I
> want to generate a list of coordinates more or less this way:
>
> for i in (beg, end, step):
> for j in (beg, end, step):
> for k in (beg, end, step):
> .........
>
> Coords = ((i1,j1,k1), (i2,j2,k2), ...,(in,jn.kn))
>
>
> Can anyone give me some advice on how to achieve this ? I got a little
> idea, but still need to keep working til i get it. Thanks in advance,
>
The pseudo-code and the intended result are two completely different things.
The pseudo-code would give you [(i1,j1,k1),(i1,j1,k2),(i1,j2,k1)...]. That
code would be written
coords = list()
for i in xrange(beg, end, step) :
for j in xrange(beg, end, step) :
for k in xrange(beg, end, step) :
coords.append((i,j,k))
for the result you gave, you would do
i = xrange(beg, end, step)
j = xrange(beg, end, step)
k = xrange(beg, end, step)
coords = zip(i,j,k)
>
> Victor
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list