Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Education > Language Artificial > Re: Python prog...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 920 of 953
Post > Topic >>

Re: Python programming question

by Rick Harrison <_nickname_@[EMAIL PROTECTED] > Jun 25, 2008 at 03:53 AM

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.
 




 4 Posts in Topic:
Python programming question
Rick Harrison <not@[EM  2008-06-22 23:17:53 
Re: Python programming question
Rick Harrison <not@[EM  2008-06-23 16:46:33 
Re: Python programming question
Carl Banks <pavlovevid  2008-06-23 18:38:47 
Re: Python programming question
Rick Harrison <_nickna  2008-06-25 03:53:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 3:29:28 CST 2008.