Re: howto handle nested for

2012-09-29 Thread Hans Mulder
On 29/09/12 03:15:24, Peter Pearson wrote: > On Fri, 28 Sep 2012 09:49:36 -0600, Ian Kelly wrote: >> >> levels = 6 >> for combination in itertools.product(xrange(n_syms), levels): >> # do stuff > n_syms = 3 levels = 6 for combination in itertools.product(xrange(n_syms), levels)

Re: howto handle nested for

2012-09-28 Thread Peter Pearson
On Fri, 28 Sep 2012 09:49:36 -0600, Ian Kelly wrote: > > levels = 6 > for combination in itertools.product(xrange(n_syms), levels): > # do stuff >>> n_syms = 3 >>> levels = 6 >>> for combination in itertools.product(xrange(n_syms), levels): ... print combination ... Traceback (most recent

Re: howto handle nested for

2012-09-28 Thread Neil Cerutti
On 2012-09-28, Laszlo Nagy wrote: > In your example, it seem that the iterable of the for loop is > always the same: range(n_sysms). It seems to be a number. Is > that true? If that is so, then here is something useful: > > import copy > > class MultiLevelIterator(object): > def __init__(self

Re: howto handle nested for

2012-09-28 Thread Ian Kelly
On Sep 28, 2012 9:49 AM, "Ian Kelly" wrote: > levels = 6 > for combination in itertools.product(xrange(n_syms), levels): > # do stuff Sorry, that should have read "product(xrange(n_syms), repeat=levels)". The repeat argument is keyword-only. -- http://mail.python.org/mailman/listinfo/python-

Re: howto handle nested for

2012-09-28 Thread Peter Otten
Neal Becker wrote: > I know this should be a fairly basic question, but I'm drawing a blank. > > I have code that looks like: > > for s0 in xrange (n_syms): > for s1 in xrange (n_syms): > for s2 in xrange (n_syms): > for s3 in xrange (n_syms): >

Re: howto handle nested for

2012-09-28 Thread Neal Becker
Neal Becker wrote: > I know this should be a fairly basic question, but I'm drawing a blank. > > I have code that looks like: > > for s0 in xrange (n_syms): > for s1 in xrange (n_syms): > for s2 in xrange (n_syms): > for s3 in xrange (n_syms): >

Re: howto handle nested for

2012-09-28 Thread Ian Kelly
On Fri, Sep 28, 2012 at 8:39 AM, Neal Becker wrote: > I know this should be a fairly basic question, but I'm drawing a blank. > > I have code that looks like: > > for s0 in xrange (n_syms): > for s1 in xrange (n_syms): > for s2 in xrange (n_syms): > for s3 in

Re: howto handle nested for

2012-09-28 Thread Tim Chase
On 09/28/12 09:39, Neal Becker wrote: > I know this should be a fairly basic question, but I'm drawing a blank. > > I have code that looks like: > > for s0 in xrange (n_syms): > for s1 in xrange (n_syms): > for s2 in xrange (n_syms): > for s3 in xrange (n_sy

Re: howto handle nested for

2012-09-28 Thread Laszlo Nagy
On 2012-09-28 16:39, Neal Becker wrote: I know this should be a fairly basic question, but I'm drawing a blank. I have code that looks like: for s0 in xrange (n_syms): for s1 in xrange (n_syms): for s2 in xrange (n_syms): for s3 in xrange (n_syms):

Re: howto handle nested for

2012-09-28 Thread Wojtek
W dniu 2012-09-28 16:42, Alister pisze: On Fri, 28 Sep 2012 10:39:32 -0400, Neal Becker wrote: I know this should be a fairly basic question, but I'm drawing a blank. I have code that looks like: for s0 in xrange (n_syms): for s1 in xrange (n_syms): for s2 in xrange (

Re: howto handle nested for

2012-09-28 Thread Alister
On Fri, 28 Sep 2012 10:39:32 -0400, Neal Becker wrote: > I know this should be a fairly basic question, but I'm drawing a blank. > > I have code that looks like: > > for s0 in xrange (n_syms): > for s1 in xrange (n_syms): > for s2 in xrange (n_syms): > for

howto handle nested for

2012-09-28 Thread Neal Becker
I know this should be a fairly basic question, but I'm drawing a blank. I have code that looks like: for s0 in xrange (n_syms): for s1 in xrange (n_syms): for s2 in xrange (n_syms): for s3 in xrange (n_syms): for s4 in range (n_syms):