Re: counting using variable length string as base

2008-04-01 Thread rootkill
On Mar 27, 8:15 am, Grimsqueaker <[EMAIL PROTECTED]> wrote: > Hi, I'm fairly new to Python and to this list. I have a problem that > is driving me insane, sorry if it seems simple to everyone, I've been > fighting with it for a while. :)) > > I want to take a variable length string and use it as a

Re: counting using variable length string as base

2008-04-01 Thread Paul Rubin
Grimsqueaker <[EMAIL PROTECTED]> writes: > Basically I want to find every possible order of every combination. > Its easy if you know how many characters there will be in your string > (use nested for loops), but I am stuck with the variable length > string. I think I have to use a generator but I'

Re: counting using variable length string as base

2008-04-01 Thread David Fraser
On Mar 31, 8:18 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 31 Mar 2008 09:30:00 -0300, Graeme Glass <[EMAIL PROTECTED]> > escribió: > > > On Mar 27, 11:01 am, Peter Otten <[EMAIL PROTECTED]> wrote: > >> a b c aa ab ac ba bb bc ca cb cc aaa aab aac aba abb abc aca acb acc > >> baa

Re: counting using variable length string as base

2008-03-31 Thread Gabriel Genellina
En Mon, 31 Mar 2008 09:30:00 -0300, Graeme Glass <[EMAIL PROTECTED]> escribió: > On Mar 27, 11:01 am, Peter Otten <[EMAIL PROTECTED]> wrote: >> 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 > > Here is a cool solution we came up

Re: counting using variable length string as base

2008-03-31 Thread Graeme Glass
On Mar 27, 11:01 am, Peter Otten <[EMAIL PROTECTED]> wrote: > 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(di

Re: counting using variable length string as base

2008-03-27 Thread castironpi
On Mar 27, 4:01 am, Peter Otten <[EMAIL PROTECTED]> wrote: > 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(dig

Re: counting using variable length string as base

2008-03-27 Thread Peter Otten
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(di

Re: counting using variable length string as base

2008-03-27 Thread Grimsqueaker
OK, got that. If I use: for x in string_cartesian_product('abc'): print x I get: a b c What am I not understanding? Thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: counting using variable length string as base

2008-03-27 Thread Steven D'Aprano
On Thu, 27 Mar 2008 00:33:21 -0700, Grimsqueaker wrote: > That seems to give me the items in the list back in an iterator. Am I > using it incorrectly? Given an iterator, you use it like this: for item in iterator: print item # or do something else If you're sure that the iterator is relat

Re: counting using variable length string as base

2008-03-27 Thread Diez B. Roggisch
Grimsqueaker schrieb: > That seems to give me the items in the list back in an iterator. Am I > using it incorrectly? No. Just put a list() around it. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: counting using variable length string as base

2008-03-27 Thread castironpi
On Mar 27, 2:33 am, Grimsqueaker <[EMAIL PROTECTED]> wrote: > That seems to give me the items in the list back in an iterator. Am I > using it incorrectly? Use list( it ). -- http://mail.python.org/mailman/listinfo/python-list

Re: counting using variable length string as base

2008-03-27 Thread Grimsqueaker
That seems to give me the items in the list back in an iterator. Am I using it incorrectly? -- http://mail.python.org/mailman/listinfo/python-list

Re: counting using variable length string as base

2008-03-26 Thread Dan Bishop
On Mar 27, 1:15 am, Grimsqueaker <[EMAIL PROTECTED]> wrote: > Hi, I'm fairly new to Python and to this list. I have a problem that > is driving me insane, sorry if it seems simple to everyone, I've been > fighting with it for a while. :)) > > I want to take a variable length string and use it as a

counting using variable length string as base

2008-03-26 Thread Grimsqueaker
Hi, I'm fairly new to Python and to this list. I have a problem that is driving me insane, sorry if it seems simple to everyone, I've been fighting with it for a while. :)) I want to take a variable length string and use it as a base for counting, eg. given the string 'abc' the sequence would be: