[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: counting using variable length string as base
From: Peter Otten <__peter__ () web ! de>
Date: 2008-03-27 9:01:39
Message-ID: fsfnpi$hvh$02$1 () news ! t-online ! com
[Download RAW message or body]
Grimsqueaker wrote:
> That seems to give me the items in the list back in an iterator. Am I
> using it incorrectly?
With Dan's functions in cartesian.py you can do the following:
>>> from cartesian import *
>>> def count(digits):
... args = []
... while 1:
... args.append(digits)
... for n in string_cartesian_product(*args):
... yield n
...
>>> from itertools import islice
>>> print " ".join(islice(count("abc"), 30))
a b c aa ab ac ba bb bc ca cb cc aaa aab aac aba abb abc aca acb acc baa bab
bac bba bbb bbc bca bcb bcc
Peter
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic