Advertisement
rfmonk

random_sample.py

Jan 23rd, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # Give me 5 random words
  4. # out of the system dict
  5. import random
  6.  
  7. with open('/usr/share/dict/words.pre-dictionaries-common', 'rt') as f:
  8.     words = f.readlines()
  9. words = [w.rstrip() for w in words]
  10.  
  11. for w in random.sample(words, 5):
  12.     print w
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement