On 29/09/12 03:15:24, Peter Pearson wrote:
> On Fri, 28 Sep 2012 09:49:36 -0600, Ian Kelly <ian.g.ke...@gmail.com> 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 call last):
>   File "<stdin>", line 1, in <module>
> TypeError: 'int' object is not iterable

>>> n_syms = 3
>>> levels = 6
>>> for combination in itertools.product(xrange(n_syms), repeat=levels):
...     print combination
...
(0, 0, 0, 0, 0, 0)
(0, 0, 0, 0, 0, 1)
(0, 0, 0, 0, 0, 2)
(0, 0, 0, 0, 1, 0)
(0, 0, 0, 0, 1, 1)
(0, 0, 0, 0, 1, 2)
(0, 0, 0, 0, 2, 0)
(0, 0, 0, 0, 2, 1)
(0, 0, 0, 0, 2, 2)
(0, 0, 0, 1, 0, 0)

etc.


Hope this helps,

-- HansM



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to