Re: Most elegant way to generate 3-char sequence

2006-06-12 Thread Bruno Desthuilliers
James Stroud a écrit : > SuperHik wrote: > >> and the winner is... :D >> David Isaac wrote: >> >>> alpha = string.lowercase >>> x=(a+b+c for a in alpha for b in alpha for c in alpha) >> >> >> >> > > Not necessarily vying for winner, but David's solution is highly > specific as it doesn't do so w

Re: [OT] Most elegant way to generate 3-char sequence

2006-06-12 Thread Bruno Desthuilliers
John Machin a écrit : > On 10/06/2006 7:49 AM, Rob Cowie wrote: (snip) >> >> def generator(): >> for char in alpha: > > > Why stop at two spaces? One-space indentation is syntactically correct :-) I very often uses 2-spaces indent when posting here, to avoid problems with wrapping. -- http:

Re: Most elegant way to generate 3-char sequence

2006-06-11 Thread Petr Jakes
sam wrote: > I have found that the more elegant the code is, the harder it is for me > to understand what it is trying to accomplish. It is my opinion that > "Keep It Simple" wins over elegance. When I have had the urge to get > elegant, I make sure I comment the elegance so my less elegant > co-wo

Re: Most elegant way to generate 3-char sequence

2006-06-11 Thread sam
I have found that the more elegant the code is, the harder it is for me to understand what it is trying to accomplish. It is my opinion that "Keep It Simple" wins over elegance. When I have had the urge to get elegant, I make sure I comment the elegance so my less elegant co-workers can figure out

Re: Most elegant way to generate 3-char sequence

2006-06-11 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> See the actual question: >> >> >How would you construct a generator to acheive this? > > > if you don't think the context provided by the subject line and the > sentence before the question is important, how come you're so sure what > "this" ref

Re: Most elegant way to generate 3-char sequence

2006-06-11 Thread Fredrik Lundh
James Stroud wrote: > See the actual question: > > >How would you construct a generator to acheive this? if you don't think the context provided by the subject line and the sentence before the question is important, how come you're so sure what "this" refers to ? -- http://mail.python.org

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread Roberto Bonvallet
2006/6/10, SuperHik <[EMAIL PROTECTED]>: > > Not necessarily vying for winner, but David's solution is highly > > specific as it doesn't do so well for something like > > > > aaa > >

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread [EMAIL PROTECTED]
I'm not sure if you ever got a good answer. I for one am too lazy to look up the pages I found... but - check out http://aspn.activestate.com/ASPN/search?query=combinations§ion=PYTHONCKBK&type=Subsection Tons of nice recipes... Personally I liked the one that dynamically generated a nested functi

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
Steve Holden wrote: > James Stroud wrote: > >> SuperHik wrote: >> >>> and the winner is... :D >>> David Isaac wrote: >>> >>> alpha = string.lowercase x=(a+b+c for a in alpha for b in alpha for c in alpha) >>> >>> >>> >>> >> >> Not necessarily vying for winner, but David's solution is hig

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
James Stroud wrote: > SuperHik wrote: > >> James Stroud wrote: >> >>> SuperHik wrote: >>> and the winner is... :D David Isaac wrote: > alpha = string.lowercase > x=(a+b+c for a in alpha for b in alpha for c in alpha) >>> >>> Not necessarily vying for

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
Steve Holden wrote: > James Stroud wrote: > >> SuperHik wrote: >> >>> and the winner is... :D >>> David Isaac wrote: >>> >>> alpha = string.lowercase x=(a+b+c for a in alpha for b in alpha for c in alpha) >>> >>> >>> >>> >> >> Not necessarily vying for winner, but David's solution is hig

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
Steve Holden wrote: > James Stroud wrote: > >> Rob Cowie wrote: >> >>> Hi all, >>> >>> I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', >>> 'abb', 'abc' etc. all the way to 'zzz'. >>> >>> How would you construct a generator to acheive this? >>> >>> A simple, working but some

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
SuperHik wrote: > James Stroud wrote: > >> SuperHik wrote: >> >>> and the winner is... :D >>> David Isaac wrote: >>> alpha = string.lowercase x=(a+b+c for a in alpha for b in alpha for c in alpha) >>> >>> >>> >>> >> >> Not necessarily vying for winner, but David's solution is highly >>

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread Steve Holden
James Stroud wrote: > SuperHik wrote: > >>and the winner is... :D >>David Isaac wrote: >> >> >>>alpha = string.lowercase >>>x=(a+b+c for a in alpha for b in alpha for c in alpha) >> >> >> > > Not necessarily vying for winner, but David's solution is highly > specific as it doesn't do so well for

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread Steve Holden
James Stroud wrote: > Rob Cowie wrote: > >>Hi all, >> >>I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', >>'abb', 'abc' etc. all the way to 'zzz'. >> >>How would you construct a generator to acheive this? >> >>A simple, working but somewhat inelegant solution is... >> >>alph

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread SuperHik
James Stroud wrote: > SuperHik wrote: >> and the winner is... :D >> David Isaac wrote: >> >>> alpha = string.lowercase >>> x=(a+b+c for a in alpha for b in alpha for c in alpha) >> >> >> > > Not necessarily vying for winner, but David's solution is highly > specific as it doesn't do so well for s

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread John Machin
On 10/06/2006 7:01 PM, Rob Cowie wrote: > John Machin wrote: >> On 10/06/2006 7:49 AM, Rob Cowie wrote: >>> Hi all, >>> >>> I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', >>> 'abb', 'abc' etc. all the way to 'zzz'. >>> >>> How would you construct a generator to acheive this

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread Fredrik Lundh
Rob Cowie wrote: >> Why type all that punctuation? > > What punctuation? ['','','','']['','','','']['','','',''] (also see david isaac's post) -- http://mail.python.org/mailman/listinfo/python-list

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread Rob Cowie
John Machin wrote: > On 10/06/2006 7:49 AM, Rob Cowie wrote: > > Hi all, > > > > I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', > > 'abb', 'abc' etc. all the way to 'zzz'. > > > > How would you construct a generator to acheive this? > > > > A simple, working but somewhat in

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
SuperHik wrote: > and the winner is... :D > David Isaac wrote: > >> alpha = string.lowercase >> x=(a+b+c for a in alpha for b in alpha for c in alpha) > > > Not necessarily vying for winner, but David's solution is highly specific as it doesn't do so well for something like a

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread SuperHik
and the winner is... :D David Isaac wrote: > alpha = string.lowercase > x=(a+b+c for a in alpha for b in alpha for c in alpha) -- http://mail.python.org/mailman/listinfo/python-list

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
Rob Cowie wrote: > Hi all, > > I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', > 'abb', 'abc' etc. all the way to 'zzz'. > > How would you construct a generator to acheive this? > > A simple, working but somewhat inelegant solution is... > > alpha = ['a','b','c','d'] #sh

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread David Isaac
alpha = string.lowercase x=(a+b+c for a in alpha for b in alpha for c in alpha) -- http://mail.python.org/mailman/listinfo/python-list

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread John Machin
On 10/06/2006 7:49 AM, Rob Cowie wrote: > Hi all, > > I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', > 'abb', 'abc' etc. all the way to 'zzz'. > > How would you construct a generator to acheive this? > > A simple, working but somewhat inelegant solution is... You're not

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread Grant Edwards
On 2006-06-09, Rob Cowie <[EMAIL PROTECTED]> wrote: > Hi all, > > I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', > 'abb', 'abc' etc. all the way to 'zzz'. > > How would you construct a generator to acheive this? > > A simple, working but somewhat inelegant solution is... >

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread David Isaac
"Rob Cowie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > alpha = ['a','b','c','d'] #shortened for brevity > alpha2 = ['a','b','c','d'] > alpha3 = ['a','b','c','d'] > > def generator(): > for char in alpha: > for char2 in alpha2: > for char3 in alpha3: > yield c

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
Rob Cowie wrote: > Hi all, > > I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', > 'abb', 'abc' etc. all the way to 'zzz'. > > How would you construct a generator to acheive this? > > A simple, working but somewhat inelegant solution is... > > alpha = ['a','b','c','d'] #sh

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
Rob Cowie wrote: > Hi all, > > I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', > 'abb', 'abc' etc. all the way to 'zzz'. > > How would you construct a generator to acheive this? > > A simple, working but somewhat inelegant solution is... > > alpha = ['a','b','c','d'] #sh

Most elegant way to generate 3-char sequence

2006-06-09 Thread Rob Cowie
Hi all, I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', 'abb', 'abc' etc. all the way to 'zzz'. How would you construct a generator to acheive this? A simple, working but somewhat inelegant solution is... alpha = ['a','b','c','d'] #shortened for brevity alpha2 = ['a','b'