In article
<4576be6e-37db-45ea-b2a8-d83ef6802533@[EMAIL PROTECTED]
>,
Carl Banks <pavlovevidence@[EMAIL PROTECTED]
> wrote:
> im****t random
> initials = ['b', 'c', 'd']
> medials = ['a', 'i', 'u']
> finals = [' ', 'n', 's']
Thanks for that. I think random.shuffle will be a lot of fun to use in
many ways.
> And if you really want to be slick, and you have the latest beta of
> Python (2.6) you can use itertools.product:
>
> im****t itertools, random
> syllables = list(itertools.product('bcd','aiu',' ns'))
> random.shuffle(syllables)
> out_file = open("syllables.txt","w")
> for syllable in syllables:
> out_file.write(x+"\n")
> out_file.close()
Wow, that is amazingly compact. I don't have 2.6 yet, I need to focus
on the fundamentals before I start chasing the latest versions, but
after seeing your example there I've looked at a few web pages about
itertools and I'm impressed -- it's a great invention.


|