[SciPy-User] [SciPy-user] Looping over one variable keeping the others constant

Andrew York Andrew.G.York+scipy@gmail....
Fri Apr 13 15:51:50 CDT 2012


I might be missing the point. Does the OP want something as simple as:

for i in range(3):
    for j in range(3):
        print i, j

On Fri, Apr 13, 2012 at 3:21 PM, Zachary Pincus <zachary.pincus@yale.edu>wrote:

> > x,y
> > 1,1
> > 2,1
> > 3,1
> > 1,2
> > 2,2
> > 3,2
> >
>
> If you just want integer increments like a counter (as in the above), you
> could use numpy.ndindex, e.g.:
>
> In [20]: numpy.array(list(numpy.ndindex(2,3)))+1
> Out[20]:
> array([[1, 1],
>       [1, 2],
>       [1, 3],
>       [2, 1],
>       [2, 2],
>       [2, 3]])
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120413/4c816e9e/attachment.html 


More information about the SciPy-User mailing list