From: proteanthread on 18 Apr 2010 18:17 On Apr 17, 12:19 pm, Cousin Stanley <cousinstan...(a)gmail.com> wrote: > > I never thought of using python this way, > > i'll give it a try, thanks stan. > > #!/usr/bin/env python > > ''' > Create a random word list > > Code_By ...... Stanley C. Kitching > Code_Date .... 2010-01-17 > ''' > > import random > > nwords = 50 # sample size > nwpl = 5 # number words per line > > fin = open( '/usr/share/dict/words' ) # input file > > list_words = [ ] > > for this_word in fin : > list_words.append( this_word.strip() ) > > fin.close() > > sample = random.sample( list_words , nwords ) > > print '\n ' , > > wnum = 0 > > for this_word in sample : > if wnum == nwpl : > print '\n ' , > wnum = 0 > print this_word , > > wnum += 1 > > print '\n\n Number of Words ....' , len( sample ) > > # --------------------------------------------------------------- > > The input file /usr/share/dict/words is just a list of words > 1 word per line .... change path as needed .... > > If you don't have a word list to use as an input file > let me know .... > > -- > Stanley C. Kitching > Human Being > Phoenix, Arizona Got It! Thanks, Stan!
From: Cousin Stanley on 18 Apr 2010 21:27 > Got It! Thanks, Stan! You're welcome .... -- Stanley C. Kitching Human Being Phoenix, Arizona
First
|
Prev
|
Pages: 1 2 Prev: .MP3 to .AAC converter sought Next: QT Lite & QuickTime Alternative 3.2.2 |