Tuple of coordinates
Benjamin Kaplan
benjamin.kaplan at case.edu
Thu May 29 09:47:10 EDT 2008
On Thu, May 29, 2008 at 8:16 AM, victor.herasme at gmail.com <
victor.herasme at gmail.com> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080529/cd0d6de1/attachment-0001.html>
More information about the Python-list
mailing list